Groupging columns with check boxes

2 posts, 0 answers
  1. Prasad
    Prasad avatar
    40 posts
    Member since:
    Sep 2011

    Posted 26 Sep 2013 Link to this post

    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.
  2. Konstantin Dikov
    Admin
    Konstantin Dikov avatar
    1793 posts

    Posted 01 Oct 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top