Hi team,
I have one problem to fix this issue with my simple grid (no hierarchie) using one Dataset as source. The Dataset is preserved using session (week_id, price, discount). The grid generate four ajax pages and pager is working as normal (next previous and go to page). I use Edit Inline or other edit modes are causing same problem the item opened to be updated is always at firt page same level. I have tested other scenarios using codes used in demo but is similar. using last Q. Ajax is registred backside joining a masterpage radscriptmanager. Thanks. Romi
I have one problem to fix this issue with my simple grid (no hierarchie) using one Dataset as source. The Dataset is preserved using session (week_id, price, discount). The grid generate four ajax pages and pager is working as normal (next previous and go to page). I use Edit Inline or other edit modes are causing same problem the item opened to be updated is always at firt page same level. I have tested other scenarios using codes used in demo but is similar. using last Q. Ajax is registred backside joining a masterpage radscriptmanager. Thanks. Romi
| <telerik:RadGrid ID="PlanGrid" runat="server" Skin="Vista" GridLines="None" Width="100%" OnNeedDataSource="PlanGrid_NeedDataSource" |
| AutoGenerateColumns="False" AllowMultiRowEdit="True" ShowStatusBar="true" AllowPaging="True" |
| OnUpdateCommand="PlanGrid_UpdateCommand" AllowAutomaticUpdates="True" PageSize="14"> |
| <MasterTableView DataKeyNames="Week" Width="100%" CommandItemDisplay="Top" EditMode="InPlace" > |
| <Columns> |
| <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn"> |
| <ItemStyle CssClass="MyImageButton" /> |
| </telerik:GridEditCommandColumn> |
| <telerik:GridTemplateColumn UniqueName="CheckBoxTemplateColumn"> |
| <HeaderTemplate> |
| <asp:CheckBox id="headerChkbox" OnCheckedChanged="ToggleSelectedState" AutoPostBack="True" runat="server"></asp:CheckBox> |
| </HeaderTemplate> |
| <ItemTemplate> |
| <asp:CheckBox id="CheckBox1" OnCheckedChanged="ToggleRowSelection" AutoPostBack="True" runat="server"></asp:CheckBox> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridBoundColumn UniqueName="Week" SortExpression="Week" HeaderText="Week" ReadOnly="true" |
| DataField="Week" /> |
| <telerik:GridBoundColumn UniqueName="Days_1d" HeaderText="Price" |
| DataField="Days_1d" > |
| <ItemStyle Width="100px" /> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn UniqueName="Days_promo" HeaderText="Discount(%)" |
| DataField="Days_promo" DataType="System.Int32"> |
| <ItemStyle Width="70px" /> |
| </telerik:GridBoundColumn> |
| </Columns> |
| <EditFormSettings ColumnNumber="2" CaptionDataField="Week" CaptionFormatString="Edit properties of Week {0}"> |
| <FormTableItemStyle Wrap="False"></FormTableItemStyle> |
| <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle> |
| <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" BackColor="White" |
| Width="100%" /> |
| <FormTableStyle CellSpacing="0" CellPadding="2" Height="110px" BackColor="White" /> |
| <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle> |
| <EditColumn ButtonType="ImageButton" InsertText="Insert Order" UpdateText="Update week" |
| UniqueName="EditCommandColumn1" CancelText="Cancel"> |
| </EditColumn> |
| <FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow"></FormTableButtonRowStyle> |
| </EditFormSettings> |
| </MasterTableView> |
| <ClientSettings EnableRowHoverStyle="true"> |
| </ClientSettings> |
| <PagerStyle Mode="NextPrevAndNumeric" /> |
| </telerik:RadGrid> |
| //CODE |
| protected void PlanGrid_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) |
| { |
| this.PlanGrid.DataSource = PlanningData; //is a Dataset |
| } |
| protected void PlanGrid_ItemPreRender(object sender, EventArgs e) |
| { |
| ((sender as GridDataItem)["CheckBoxTemplateColumn"].FindControl("CheckBox1") as CheckBox).Checked = (sender as GridDataItem).Selected; |
| } |
| protected void ToggleRowSelection(object sender, EventArgs e) |
| { |
| ((sender as CheckBox).Parent.Parent as GridItem).Selected = (sender as CheckBox).Checked; |
| } |
| protected void ToggleSelectedState(object sender, EventArgs e) |
| { |
| if ((sender as CheckBox).Checked == true) |
| { |
| foreach (GridDataItem dataItem in PlanGrid.MasterTableView.Items) |
| { |
| (dataItem.FindControl("CheckBox1") as CheckBox).Checked = true; |
| dataItem.Selected = true; |
| } |
| } |
| else |
| { |
| foreach (GridDataItem dataItem in PlanGrid.MasterTableView.Items) |
| { |
| (dataItem.FindControl("CheckBox1") as CheckBox).Checked = false; |
| dataItem.Selected = false; |
| } |
| } |
| } |
| protected void PlanGrid_UpdateCommand(object source, Telerik.Web.UI.GridCommandEventArgs e) |
| { |
| PlanGrid.MasterTableView.EditMode = GridEditMode.EditForms; |
| GridEditableItem eeditedItem = e.Item as GridEditableItem; |
| GridEditManager editMan = editedItem.EditManager; |
| foreach (GridColumn column in e.Item.OwnerTableView.RenderColumns) |
| { |
| if (column is IGridEditableColumn) |
| { |
| IGridEditableColumn editableCol = (column as IGridEditableColumn); |
| if (editableCol.IsEditable) |
| { |
| IGridColumnEditor editor = editMan.GetColumnEditor(editableCol); |
| string editoreditorType = editor.ToString(); |
| string editorText = "unknown"; |
| object editorValue = null; |
| if (editor is GridTextColumnEditor) |
| { |
| editorText = (editor as GridTextColumnEditor).Text; |
| editorValue = (editor as GridTextColumnEditor).Text; |
| } |
| if (editor is GridBoolColumnEditor) |
| { |
| editorText = (editor as GridBoolColumnEditor).Value.ToString(); |
| editorValue = (editor as GridBoolColumnEditor).Value; |
| } |
| if (editor is GridDropDownColumnEditor) |
| { |
| editorText = (editor as GridDropDownColumnEditor).SelectedText + "; " + |
| (editor as GridDropDownColumnEditor).SelectedValue; |
| editorValue = (editor as GridDropDownColumnEditor).SelectedValue; |
| } |
| try |
| { |
| DataRow[] changedRows = PlanningData.Tables[0].Select("Week= " + editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["Week"]); |
| changedRows[0][column.UniqueName] = editorValue; |
| PlanningData.Tables[0].AcceptChanges(); |
| } |
| catch (Exception ex) |
| { |
| PlanGrid.Controls.Add(new LiteralControl("<strong>Error '" + column.UniqueName + "'</strong> - " + ex.Message)); |
| e.Canceled = true; |
| break; |
| } |
| } |
| } |
| } |
| editedItem.Edit = false; |
| } |