Author: husted Date: Fri Dec 8 07:04:55 2006 New Revision: 484629 URL: http://svn.apache.org/viewvc?view=rev&rev=484629 Log: Extend support for flipping to a page in the datagrid, based on a key field. Clients can override ExecuteList to specify the name of the key field.
Modified: struts/sandbox/trunk/overdrive/Nexus/Web/GridControl.ascx.cs Modified: struts/sandbox/trunk/overdrive/Nexus/Web/GridControl.ascx.cs URL: http://svn.apache.org/viewvc/struts/sandbox/trunk/overdrive/Nexus/Web/GridControl.ascx.cs?view=diff&rev=484629&r1=484628&r2=484629 ============================================================================== --- struts/sandbox/trunk/overdrive/Nexus/Web/GridControl.ascx.cs (original) +++ struts/sandbox/trunk/overdrive/Nexus/Web/GridControl.ascx.cs Fri Dec 8 07:04:55 2006 @@ -593,41 +593,56 @@ /// <summary> - /// Store the item key field name. + /// Obtain the item key field name. /// </summary> /// <param name="context">The context to examine</param> - /// <param name="key">The name of the item key field</param> + /// <returns>Name of key field</returns> /// - protected void SetItemKey(IDictionary context, string key) + protected object GetItemKey(IDictionary context) { - context[ITEM_KEY] = key; + if (context==null) return null; + return context[ITEM_KEY]; } /// <summary> - /// Obtain the item key field name. + /// Store the item key field name. /// </summary> /// <param name="context">The context to examine</param> - /// <returns>Name of key field</returns> + /// <param name="key">The name of the item key field</param> /// - protected object GetItemKey(IDictionary context) + protected void SetItemKey(IDictionary context, string key) { - return context[ITEM_KEY]; + if (context!=null) context[ITEM_KEY] = key; } /// <summary> - /// Obtain the item page from Helper, or zero if no page set. + /// Obtain the item key value for Helper. /// </summary> /// <param name="context">The context to examine</param> /// <returns>Current page number within data set</returns> /// protected object GetItemKeyValue(IDictionary context) { + if (context==null) return null; object key = context[ITEM_KEY]; if (key==null) return null; return context[key]; } /// <summary> + /// Update the item key value for Helper, especially to clear on Add. + /// </summary> + /// <param name="context">The context to examine</param> + /// <returns>Current page number within data set</returns> + /// + protected void SetItemKeyValue(IDictionary context, string val) + { + if (context==null) return; + object key = context[ITEM_KEY]; + if (key!=null) context[key] = val; + } + + /// <summary> /// Configure the DataGrid for initial display. /// </summary> /// <param name="helper">The Helper with an outcome to bind as a DataSource</param> @@ -1315,6 +1330,7 @@ { if (View_Add != null) { + SetItemKeyValue(list_Criteria, null); FindArgs f = new FindArgs(e, list_Criteria); View_Add(sender, f); }