CheckBox for grid grouping

4 posts, 0 answers
  1. Aditya
    Aditya avatar
    20 posts
    Member since:
    May 2011

    Posted 24 Jan 2012 Link to this post

    Hi,
           I need a checkbox for grid grouping.
    Regards,
        Aditya
      
  2. Abhishek
    Abhishek avatar
    45 posts
    Member since:
    Jul 2012

    Posted 24 Jan 2012 Link to this post

    Hello Aditya,

    Here i came up with one solution to your problem please have one look. Here is the code:
    <telerik:RadGrid ID="rgTesting" runat="server" GridLines="None" AllowPaging="True"
           ShowGroupPanel="true" CssClass="RadGrid" AllowSorting="True" AutoGenerateColumns="False"
           ShowStatusBar="true" GroupingSettings-RetainGroupFootersVisibility="true" GroupingEnabled="true"
           DataSourceID="Testfile">
           <MasterTableView Width="100%" DataKeyNames="ID" EditMode="InPlace">
               <GroupHeaderTemplate>
                   <asp:CheckBox ID="MyCheckBox" runat="server" Text='<%#Eval("Name") %>' />
               </GroupHeaderTemplate>
               <GroupByExpressions>
                   <telerik:GridGroupByExpression>
                       <SelectFields>
                           <telerik:GridGroupByField FieldAlias="Name" FieldName="Name"></telerik:GridGroupByField>
                       </SelectFields>
                       <GroupByFields>
                           <telerik:GridGroupByField FieldAlias="Name" FieldName="Name"></telerik:GridGroupByField>
                       </GroupByFields>
                   </telerik:GridGroupByExpression>
               </GroupByExpressions>
               <Columns>
                   <telerik:GridClientSelectColumn UniqueName="test">
                   </telerik:GridClientSelectColumn>
                   <telerik:GridBoundColumn UniqueName="ID" HeaderText="ID" DataField="ID">
                   </telerik:GridBoundColumn>
                   <telerik:GridBoundColumn UniqueName="Name" HeaderText="Name" DataField="Name">
                   </telerik:GridBoundColumn>
               </Columns>
           </MasterTableView>
           <ClientSettings>
               <Selecting AllowRowSelect="true" />
           </ClientSettings>
       </telerik:RadGrid>
       <asp:XmlDataSource ID="Testfile" runat="server" DataFile="~/XMLFiles/RadCombo.xml">
       </asp:XmlDataSource>

    I took the ref from the link: http://demos.telerik.com/aspnet-ajax/grid/examples/groupby/headerandfootertemplates/defaultcs.aspx

    Thanks,
    Abhishek K
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Aditya
    Aditya avatar
    20 posts
    Member since:
    May 2011

    Posted 24 Jan 2012 Link to this post

    Hi Abhishek,
     Thanx for the code.., but how can i access checkbox from<GroupHeaderTemplate> in code behind.

    Regards,
    Aditya

  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 24 Jan 2012 Link to this post

    Hello Aditya,

    Try the following code.
    C#:
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
     if (e.Item is GridGroupHeaderItem)
     {
       GridGroupHeaderItem item = (GridGroupHeaderItem)e.Item;
       CheckBox chk = (CheckBox)item.FindControl("CheckBox1");
     }
    }

    -Shinu.
Back to Top