This is a migrated thread and some comments may be shown as answers.

Grouping a check box column inside a RadGrid

3 Answers 155 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Adnan
Top achievements
Rank 1
Adnan asked on 12 Oct 2015, 09:32 AM

Hi,

 

i just need to group a Grid column which in fact is a check box column. It contains only checked/unchecked boxes, and i want to allow them to be grouped. Here is my part of the code. Btw, some time ago, i figured it out, but cant remember now :(

 

<Columns>
     <telerik:GridTemplateColumn UniqueName="cbDonorUniqueSelect" HeaderText="SelectAll" AllowFiltering="false" Groupable="True" ShowFilterIcon="false" HeaderStyle-Width="30px">
          <HeaderTemplate>
                <asp:CheckBox ID="cbCheckAllDonors" runat="server" AutoPostBack="True" OnCheckedChanged="cbCheckAllDonors_CheckedChanged" SkinID="" />
          </HeaderTemplate>
          <ItemTemplate>
                 <asp:CheckBox ID="cbSelectDonor" runat="server" OnCheckedChanged="cbSelectDonor_CheckedChange"/>
          </ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>​

3 Answers, 1 is accepted

Sort by
0
Adnan
Top achievements
Rank 1
answered on 12 Oct 2015, 09:39 AM
Sorry, here is the whole part of Grid code...
 
<telerik:RadGrid ID="gvDonors" runat="server" AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True" CellSpacing="0" OnSortCommand="gvDonor_SortCommand" OnGroupsChanging="gvDonor_GroupsChanging"
                 OnPageIndexChanged="gvDonor_PageIndexChanged" PageSize="10" OnPreRender="gvDonor_PreRender" ShowGroupPanel="True" OnPageSizeChanged="gvDonor_PageSizeChanged" ShowFooter="True" Skin="Sunset" style="table-layout:fixed;" AutoGenerateColumns="False" GridLines="None" OnNeedDataSource="gvDonor_NeedDataSource">
    <ClientSettings AllowDragToGroup="True" AllowColumnsReorder="True" ReorderColumnsOnClient="True"></ClientSettings>
    <GroupingSettings CaseSensitive="false" />
    <GroupPanel Text="<%$Resources:localization, lblGroupingText%>"></GroupPanel>
    <MasterTableView DataKeyNames="ID" AutoGenerateColumns="False" ClientDataKeyNames="ID" Width="100%">
        <Columns>
            <telerik:GridTemplateColumn UniqueName="cbDonorUniqueSelect" HeaderText="SelectAll"  AllowFiltering="false" Groupable="True" ShowFilterIcon="false" HeaderStyle-Width="30px">
            <HeaderTemplate>
                <asp:CheckBox ID="cbCheckAllDonors" runat="server" AutoPostBack="True" OnCheckedChanged="cbCheckAllDonors_CheckedChanged" SkinID="" />
            </HeaderTemplate>
            <ItemTemplate>
                <asp:CheckBox ID="cbSelectDonor" runat="server" OnCheckedChanged="cbSelectDonor_CheckedChange"/>
            </ItemTemplate>
            </telerik:GridTemplateColumn>                                                    
            <telerik:GridBoundColumn DataField="ID" FilterControlAltText="Filter ID column" HeaderText="ID" ReadOnly="True" SortExpression="ID" UniqueName="ID" CurrentFilterFunction="EqualTo" AutoPostBackOnFilter="true" ShowFilterIcon="false" HeaderStyle-Width="30px" FilterControlWidth="30px"></telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Name" FilterControlAltText="Filter Name column" HeaderText="<%$Resources:localization, lblDonorName%>" SortExpression="Name" UniqueName="Name" CurrentFilterFunction="Contains" AutoPostBackOnFilter="true" ShowFilterIcon="false" HeaderStyle-Width="150px" FilterControlWidth="145px"></telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="ShortName" FilterControlAltText="Filter ShortName column" HeaderText="<%$Resources:localization, lblShortDonorName%>" SortExpression="ShortName" UniqueName="ShortName" CurrentFilterFunction="Contains" AutoPostBackOnFilter="true" ShowFilterIcon="false" HeaderStyle-Width="150px" FilterControlWidth="145px"></telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Country" FilterControlAltText="Filter Country column" HeaderText="<%$Resources:localization, lblDonorCountry%>" SortExpression="Country" UniqueName="Country" CurrentFilterFunction="Contains" AutoPostBackOnFilter="true" ShowFilterIcon="false"  HeaderStyle-Width="200px" FilterControlWidth="230px"></telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Status" FilterControlAltText="Filter Status column" HeaderText="<%$Resources:localization, lblStatus%>" SortExpression="Status" UniqueName="Status" CurrentFilterFunction="Contains" AutoPostBackOnFilter="true" ShowFilterIcon="false"  HeaderStyle-Width="100px" FilterControlWidth="80px"></telerik:GridBoundColumn>
        </Columns>
        <PagerStyle AlwaysVisible="True"/>
    </MasterTableView>
</telerik:RadGrid>
0
Adnan
Top achievements
Rank 1
answered on 14 Oct 2015, 06:52 AM

UP

:(

0
Viktor Tachev
Telerik team
answered on 15 Oct 2015, 08:40 AM
Hi Adnan,

In order for RadGrid to group the data it uses the values for a given field in the data source. However, the template column you are trying to group by does not seem to be bound to a data source field. It displays only CheckBoxes. In that case there are no values the grid can use to perform the grouping.

You can bind the checkbox column to a boolean field in the data source. This way the data can be grouped cased on the value for the field in the data source.

Regards,
Viktor Tachev
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
Grid
Asked by
Adnan
Top achievements
Rank 1
Answers by
Adnan
Top achievements
Rank 1
Viktor Tachev
Telerik team
Share this question
or