or
<telerik:GridTemplateColumn UniqueName="Resubmitted" DataField="Resubmitted" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left" HeaderStyle-Width="20%" > <HeaderTemplate> <asp:CheckBox id="headerChkbox" OnCheckedChanged="ToggleSelectedState" AutoPostBack="true" runat="server" Text=" resubmitted" ></asp:CheckBox> </HeaderTemplate> <EditItemTemplate> <asp:CheckBox id="chkResubmittedEdit" runat="server" Checked='<%# Bind("Resubmitted") %>'/> </EditItemTemplate> <ItemTemplate> <asp:CheckBox id="chkResubmittedItem" runat="server" Checked='<%# Eval("Resubmitted") %>' /> </ItemTemplate> </telerik:GridTemplateColumn>protected void ToggleSelectedState(object sender, EventArgs e) { CheckBox headerCheckBox = (sender as CheckBox); try { GridDataItemCollection items = (grdClaimHist.FindControl("grdClaimDetail") as RadGrid).MasterTableView.Items; foreach (GridDataItem dataItem in items) { CheckBox chk = (dataItem.FindControl("chkResubmittedEdit") as CheckBox); chk.Checked = headerCheckBox.Checked; } } catch (Exception ex) { //continue } }Hello, I have following RadGrid containing nested GridTableViews. Every row has CheckBox and I would like to select and deselect them in ClientSide. I have following Javascript code.
function RowSelected(sender, eventArgs) { var dataItem = sender.get_masterTableView().get_dataItems()[eventArgs._itemIndexHierarchical]; var str = eventArgs._itemIndexHierarchical; if (typeof (dataItem) == "undefined") { dataItem = sender.get_detailTables()[0].get_selectedItems()[str]; } if (typeof (dataItem) == "undefined") { dataItem = sender.get_detailTables()[1].get_selectedItems()[str]; } if (isDeselecting) { if (id == dataItem._itemIndexHierarchical) { dataItem.set_selected(false); isDeselecting = false; } else id = dataItem._itemIndexHierarchical; } else if (isDeselecting == false) { id = dataItem._itemIndexHierarchical; isDeselecting = true; } } My aspx Page is declared as followed.
<telerik:RadGrid ID="RadGridSubOrganizations" runat="server" BorderStyle="Solid" AllowFilteringByColumn="false" AutoGenerateColumns="false" Visible="true" Width="100%" OnItemCommand="RadGridSubOrganizations_ItemCommand" Height="150px" OnDetailTableDataBind="RadGridSubOrganizations_DetailTableDataBind" OnItemDataBound="RadGridSubOrganizations_ItemDataBound" SortingSettings-EnableSkinSortStyles="true" MasterTableView-ExpandCollapseColumn-Display="true" AllowSorting="false" ShowStatusBar="true" GridLines="None" HeaderStyle-BackColor="#BDBDBD"> <MasterTableView CellSpacing="-1" AllowNaturalSort="false" TableLayout="Fixed" Name="Organization" DataKeyNames="ParentOrganizationId,ChildOrganizationId,SubChildOrganizationId" ItemStyle-BackColor="#B0C4DE" GridLines="None"> <HeaderStyle CssClass="HeaderColor" /> <DetailTables> <telerik:GridTableView DataKeyNames="ParentOrganizationId,ChildOrganizationId" Width="100%" GridLines="None" HeaderStyle-BackColor="#BDBDBD" HeaderStyle-ForeColor="Black" ItemStyle-BackColor="#ADD8E6"> <DetailTables> <telerik:GridTableView DataKeyNames="ParentOrganizationId,ChildOrganizationId,SubChildOrganizationId" Width="100%" ItemStyle-BackColor="#DEF3FA" GridLines="None" HeaderStyle-BackColor="#BDBDBD" HeaderStyle-ForeColor="Black"> <%@ Control Language="vb" AutoEventWireup="false" CodeBehind="Grid.ascx.vb" Inherits="WebDBMS.Grid" %> <%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %> <telerik:RadScriptManager ID="ScriptManager" runat="server" /> <telerik:RadGrid ID="RadGrid" runat="server" Width="100%" Height="100%" Font-Names="Verdana" GridLines="Both" AllowSorting="True" ShowGroupPanel="True" Skin="Office2007" AllowPaging="True" PageSize="50" AutoPostBack="True"> <MasterTableView> <HeaderStyle Wrap="false" /> </MasterTableView> <ClientSettings AllowDragToGroup="True"> <Selecting AllowRowSelect="True" /> <Scrolling AllowScroll="True" UseStaticHeaders="True" SaveScrollPosition="True"> </Scrolling> <Resizing AllowResizeToFit="True" AllowColumnResize="True" /> <ClientEvents OnRowDblClick="RowDblClick" /> </ClientSettings> <ExportSettings ExportOnlyData="true" IgnorePaging="true"/> </telerik:RadGrid> <script type="text/javascript"> function RowDblClick(sender, args) { var grid = sender; var MasterTable = grid.get_masterTableView(); var row = MasterTable.get_dataItems()[args.get_itemIndexHierarchical()]; var cell = MasterTable.getCellByColumnUniqueName(row, "ID"); var value = cell.innerHTML; var url = "../Forms/getEditForm.aspx?key=" + __name + "&id=" + value; winopen(url, null, "toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1"); } function OpenRow() { /* Need something here */ var url = "../Forms/getEditForm.aspx?key=" + __name + "&id=" + value; winopen(url, null, "toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1"); } </script>Protected Sub rgd_Authorizers_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rgd_Authorizers.ItemCreated Dim IDPurchaseRequisition = Request.QueryString("IDPurchaseRequisition") Dim connectionString As String = DirectCast(ConfigurationManager.ConnectionStrings("Purchasing_PRS_ConnectionString").ConnectionString, String) Dim conn As New SqlConnection(connectionString) Dim comm As New SqlCommand("SELECT * FROM [PRS_PurchaseRequisitionsApprovals] WHERE IDPurchaseRequisition = @IDPurchaseRequisition", conn) comm.Connection.Open() comm.Parameters.Add("@IDPurchaseRequisition", SqlDbType.Int).Value = IDPurchaseRequisition Dim myDataAdapter As New SqlDataAdapter(comm) Dim myDataSet As New DataSet Dim dtData As New DataTable Dim dtRow As DataRow myDataAdapter.Fill(myDataSet) conn.Close() For Each dtRow In myDataSet.Tables(0).Rows Dim IDAuthorizer = dtRow.Item("IDAuthorizer") If TypeOf e.Item Is GridDataItem Then Dim item As GridDataItem = TryCast(e.Item, GridDataItem) Dim value1 As String = item("IDAuthorizer").Text If value1 = IDAuthorizer Then Dim btn_Approve As Button = DirectCast(item("TemplateColumn").Controls(0), Button) btn_Approve.Visible = False End If End If NextEnd Sub