Hi,
I use same sample as found in demo webside and have some troubles.
If i select the header checkbox items are correctly selected. If deselect this checkbox no action is performed in selected items.
I can't use the suggested ItemCreatedEvent lauching the ItemPreRender because in this case when select, only my last item is selected no others and deselecting from header checkbox is not working.
grid :OnNeedDataSource="PlanGrid_NeedDataSource" OnItemCreated="PlanGrid_ItemCreated"OnUpdateCommand="PlanGrid_UpdateCommand"
Template
u advice.
regards.
I use same sample as found in demo webside and have some troubles.
If i select the header checkbox items are correctly selected. If deselect this checkbox no action is performed in selected items.
I can't use the suggested ItemCreatedEvent lauching the ItemPreRender because in this case when select, only my last item is selected no others and deselecting from header checkbox is not working.
grid :OnNeedDataSource="PlanGrid_NeedDataSource" OnItemCreated="PlanGrid_ItemCreated"OnUpdateCommand="PlanGrid_UpdateCommand"
Template
| <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> |
| 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_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e) |
| { |
| // this will make the textbox for customer with Week ALLS not editable |
| if (e.Item is GridEditableItem && e.Item.IsInEditMode) |
| { |
| if (e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["PriceUs"] != null) |
| { |
| (e.Item as GridEditableItem)["PriceUs"].Enabled = false; |
| } |
| if (e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Week"] != null) |
| { |
| (e.Item as GridEditableItem)["Week"].Enabled = false; |
| } |
| } |
| //if (e.Item is GridDataItem) |
| //{ |
| // e.Item.PreRender += new EventHandler(PlanGrid_ItemPreRender); |
| //} |
| //} |
| } |
u advice.
regards.