Hello,
I am trialing the radgrid controls and am having an issue with the batch update mode.
I have the following html in aspx:
This grid is populated on a selected row event from another grid:
Also, I am populating the combobox that is embedded in the radgrid on the ItemDataBound Event:
Finally, I am setting each row as editable in the PreRender event:
When the "Update All" button is clicked I am iterating through each row to determine if there are updates in the ItemCommand Event:
I have tried many differnt things here but the results from the ExtractValuesFromItem is always Count=0.
How can I determine if the row has actually changed? I don't want to update every row, only the items that have actually been changed.
Thanks,
​
I am trialing the radgrid controls and am having an issue with the batch update mode.
I have the following html in aspx:
<telerik:RadGrid ID="RadGrid_MobileCheckList" runat="server" AutoGenerateColumns="False" GridLines="Vertical" AllowMultiRowEdit="true" HeaderStyle-CssClass="radGridHeaderStyle" onitemdatabound="RadGrid_MobileCheckList_ItemDataBound" onprerender="RadGrid_MobileCheckList_PreRender" onitemcommand="RadGrid_MobileCheckList_ItemCommand"> <MasterTableView DataKeyNames="MobileChecklist_ID, MobileResponseType_ID, MobileResponse_ID" EditMode="Batch" CommandItemDisplay="Bottom"> <Columns> <telerik:GridBoundColumn AllowSorting="true" HeaderStyle-Width="20%" ItemStyle-CssClass="radGridItemStyle" ReadOnly="true" DataField="Task" HeaderText="Task"></telerik:GridBoundColumn> <telerik:GridTemplateColumn HeaderStyle-Width="10%" ItemStyle-CssClass="radGridItemStyle" HeaderText="Response" UniqueName=""> <EditItemTemplate> <telerik:RadComboBox runat="server" ID="MobileChecklistGrid_RadComboBox_Response" ondatabound="MobileChecklistGrid_RadComboBox_Response_DataBound" Width="100%" DataTextField="Response" DataValueField="MobileResponse_ID"></telerik:RadComboBox> </EditItemTemplate> </telerik:GridTemplateColumn> <telerik:GridTemplateColumn HeaderStyle-Width="70%" ItemStyle-CssClass="radGridItemStyle" HeaderText="Comment"> <EditItemTemplate> <telerik:RadTextBox runat="server" ID="MobileChecklistGrid_TextBox_Comment" Width="100%" Text='<%# Eval("Comment") %>'></telerik:RadTextBox> </EditItemTemplate> </telerik:GridTemplateColumn> <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" /> </Columns> <CommandItemTemplate> <asp:Button runat="server" ID="UpdateAll" Text="Update All" CommandName="UpdateAll" /> </CommandItemTemplate> </MasterTableView> </telerik:RadGrid>This grid is populated on a selected row event from another grid:
protected void RadGrid_CheckList_ItemCommand(object sender, Telerik.Web.UI.GridCommandEventArgs e) { if (e.CommandName == "RowClick") { GridDataItem item = (GridDataItem)e.Item; string checklistId = item["Checklist_ID"].Text; DataTable table = _domain.GetMobileCheckListDetailsByCheckListId(checklistId); RadGrid_MobileCheckList.DataSource = table; RadGrid_MobileCheckList.DataBind(); } }Also, I am populating the combobox that is embedded in the radgrid on the ItemDataBound Event:
protected void RadGrid_MobileCheckList_ItemDataBound(object sender, GridItemEventArgs e) { if (e.Item is GridDataItem) { if (e.Item is GridEditableItem && e.Item.IsInEditMode) { GridEditableItem item = (GridEditableItem)e.Item; RadComboBox rcb = item.FindControl("MobileChecklistGrid_RadComboBox_Response") as RadComboBox; if (rcb != null) { int? responseTypeId = !string.IsNullOrEmpty(item.GetDataKeyValue("MobileResponseType_ID").ToString()) ? int.Parse(item.GetDataKeyValue("MobileResponseType_ID").ToString()) : (int?)null; if (responseTypeId != null) { DataTable table = _domain.GetMobileResponsesByResponseTypeID(responseTypeId); comboBox.DataSource = table; comboBox.DataValueField = table.Columns[valueField].ToString(); comboBox.DataTextField = table.Columns[textField].ToString(); comboBox.DataBind(); comboBox.SelectedIndex = -1; } } } } }Finally, I am setting each row as editable in the PreRender event:
protected void RadGrid_MobileCheckList_PreRender(object sender, EventArgs e) { foreach (GridDataItem dataItem in RadGrid_MobileCheckList.Items) { dataItem.Edit = true; } RadGrid_MobileCheckList.Rebind(); }When the "Update All" button is clicked I am iterating through each row to determine if there are updates in the ItemCommand Event:
I have tried many differnt things here but the results from the ExtractValuesFromItem is always Count=0.
protected void RadGrid_MobileCheckList_ItemCommand(object sender, GridCommandEventArgs e) { if (e.CommandName == "UpdateAll") { foreach (GridEditableItem editedItem in RadGrid_MobileCheckList.EditItems) { Hashtable newValues = new Hashtable(); Hashtable oldValues = new Hashtable(); oldValues = (Hashtable)editedItem.SavedOldValues; e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem); editedItem.ExtractValues(newValues); //I can get the items with something like this: //But I dont want to update every row everytime, I need to know which items have been actually edited. Something like an isDirty property. var test = ((RadComboBox)editedItem.Cells[3].Controls[1]).SelectedItem; var test2 = ((RadTextBox)editedItem.Cells[4].Controls[1]).Text; } } }How can I determine if the row has actually changed? I don't want to update every row, only the items that have actually been changed.
Thanks,
​