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

Groupging columns with check boxes

1 Answer 8 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Prasad
Top achievements
Rank 1
Prasad asked on 26 Sep 2013, 03:08 PM
Team,
    I have a requirement like this. Please provide solution for following scenario.
    I am constructing a grid dynamically by adding template columns with check boxes. this grid has GroupByExpressions. Please find the following code snippet for how we are construction radgrid.
<telerik:RadGrid ID="RadGrid1" AutoGenerateColumns="false" runat="server" CellSpacing="0"
           GridLines="None" Width="100%" PagerStyle-AlwaysVisible="true" >
           <%-- AllowSorting="True" PagerStyle-PageSizeControlType="RadDropDownList" AllowPaging="True"--%>
           <ClientSettings>
               <Scrolling AllowScroll="True" UseStaticHeaders="True"></Scrolling>
           </ClientSettings>
           <MasterTableView AutoGenerateColumns="False" TableLayout="fixed" DataKeyNames="ReportId"
               GroupsDefaultExpanded="True" GroupLoadMode="Client" CommandItemDisplay="None">
               <GroupByExpressions>
                   <telerik:GridGroupByExpression>
                       <SelectFields>
                           <telerik:GridGroupByField FieldName="DomainName" FieldAlias="Domain" FormatString=""
                               HeaderText=" " HeaderValueSeparator=""></telerik:GridGroupByField>
                       </SelectFields>
                       <GroupByFields>
                           <telerik:GridGroupByField SortOrder="Descending" FieldName="DomainName" FormatString=""
                               HeaderText=""></telerik:GridGroupByField>
                       </GroupByFields>
                   </telerik:GridGroupByExpression>
                   <telerik:GridGroupByExpression>
                       <SelectFields>
                           <telerik:GridGroupByField FieldName="SubjectAreaName" FieldAlias="SubjectArea" FormatString=""
                               HeaderText=" " HeaderValueSeparator=""></telerik:GridGroupByField>
                       </SelectFields>
                       <GroupByFields>
                           <telerik:GridGroupByField SortOrder="Descending" FieldName="SubjectAreaName" FormatString=""
                               HeaderText=""></telerik:GridGroupByField>
                       </GroupByFields>
                   </telerik:GridGroupByExpression>
                   <telerik:GridGroupByExpression>
                       <SelectFields>
                           <telerik:GridGroupByField FieldName="GroupName" FieldAlias="Group" FormatString=""
                               HeaderText=" " HeaderValueSeparator=""></telerik:GridGroupByField>
                       </SelectFields>
                       <GroupByFields>
                           <telerik:GridGroupByField SortOrder="Descending" FieldName="GroupName" FormatString=""
                               HeaderText=""></telerik:GridGroupByField>
                       </GroupByFields>
                   </telerik:GridGroupByExpression>
               </GroupByExpressions>
               <Columns>
               </Columns>
           </MasterTableView>
       </telerik:RadGrid>

I am adding code snippet :-

private void AddGridTemplateColumnsToSmartReportGrid(ref DataTable dt)
    {
        entities obj = new entities();
 
        var SRActions = (from col in obj.SecurityParameters select new { SRPermissionId = col.SecurityParameterID, SRPermissionName = col.SecurityParameterName }).ToList();
 
        List<string> cols = (from col in SRActions
                   select col.SRPermissionName).ToList<string>();
 
        dtSRActions = SRActions.GetDataTable();
        Session["dtSRActions"] = dtSRActions;
 
        for (int i = 0; i < cols.Count; i++)
        {
            GridTemplateColumn tempcol = new GridTemplateColumn();
            tempcol.ItemTemplate = new MyCheckbox(i);
            tempcol.ItemStyle.HorizontalAlign = HorizontalAlign.Center;
            tempcol.HeaderStyle.HorizontalAlign = HorizontalAlign.Center;
            tempcol.ItemStyle.Width = Unit.Pixel(60);
            tempcol.HeaderStyle.Width = Unit.Pixel(60);
            tempcol.HeaderText = cols[i];
            RadGrid1.MasterTableView.Columns.Add(tempcol);
            dt.Columns.Add(cols[i],typeof(string));
        }
         
    }
My requirement is, How to add check box in group header for each column. Please find attached screen shot for my requirement.

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 01 Oct 2013, 11:35 AM
Hi Prasad,

Could you please refer to the attached sample page which demonstrates how to achieve the requested functionality. Please note that you should implement the demonstrated approach for every column.

Furthermore, fol aligning the header to correspond to the column within the grid, please refer to the following help article: "Grid - Aligning Items in GroupHeader".

Hope that helps.

 

Regards,
Konstantin Dikov
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Ajax
Asked by
Prasad
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or