Nested Grouping

4 posts, 0 answers
  1. lupotana
    lupotana avatar
    73 posts
    Member since:
    Nov 2006

    Posted 12 Oct 2012 Link to this post

    Hi,
    I could try to make a nested grouping with RadGrid.
    The first field to group is "Campionato" (Champion),
    the second is "Gara" (Game)

    I can do this work with drag &drop column (see attahced Correct.png).
    but I want that this grouping is fixed when load Grid (client or server)

    I can add GridGroupByField in aspx 
    <telerik:RadGrid ID="gvList" runat="server" PageSize="20" AllowSorting="True" AllowPaging="True"
                       ShowGroupPanel="True" AutoGenerateColumns="False" GridLines="None">
                       <PagerStyle Mode="NumericPages"></PagerStyle>
                       <MasterTableView Width="100%" GroupLoadMode="Server" TableLayout="Fixed">
                           <GroupByExpressions>
                               <telerik:GridGroupByExpression>
                                   <SelectFields>
                                       <telerik:GridGroupByField FieldAlias="CAMPIONATO" FieldName="C01_B04_CODE_FK"></telerik:GridGroupByField>
                                       <telerik:GridGroupByField FieldAlias="GARA" FieldName="C01_GARA_PK"></telerik:GridGroupByField>
                                   </SelectFields>
                                   <GroupByFields>
                                       <telerik:GridGroupByField FieldName="C01_B04_CODE_FK"></telerik:GridGroupByField>
                                   </GroupByFields>
                               </telerik:GridGroupByExpression>
                           </GroupByExpressions>
    or use che code behind
     
    GridGroupByExpression expression = new GridGroupByExpression();
            GridGroupByField existing = expression.SelectFields.FindByName("C01_GARA_PK");
      
            GridGroupByField field = new GridGroupByField();
            field.FieldName = "C01_B04_CODE_FK";
            field.FieldAlias = "CAMPIONATO";
      
            GridGroupByField field = new GridGroupByField();
            field.FieldName = "C01_GARA_PK";
            field.FieldAlias = "GARA";
      
            expression.SelectFields.Add(field);
      
            gvList.MasterTableView.GroupByExpressions.Add(expression);
            gvList.Rebind();

    but the result is wrong (see attached Wrong.png)

    HoW do i do ?
  2. Radoslav
    Admin
    Radoslav avatar
    1564 posts

    Posted 17 Oct 2012 Link to this post

    Hello Marco,

    To achieve the desired functionality you need to add two different GridGroupByExpressions. For example:
    <GroupByExpressions>
                    <telerik:GridGroupByExpression>
                        <SelectFields>
                            <telerik:GridGroupByField FieldAlias="CAMPIONATO" FieldName="C01_B04_CODE_FK"></telerik:GridGroupByField>
                        </SelectFields>
                        <GroupByFields>
                            <telerik:GridGroupByField FieldName="C01_B04_CODE_FK"></telerik:GridGroupByField>
                        </GroupByFields>
                    </telerik:GridGroupByExpression>
                    <telerik:GridGroupByExpression>
                        <SelectFields>
                            <telerik:GridGroupByField FieldAlias="GARA" FieldName="C01_GARA_PK"></telerik:GridGroupByField>
                        </SelectFields>
                        <GroupByFields>
                           <telerik:GridGroupByField FieldAlias="GARA" FieldName="C01_GARA_PK"></telerik:GridGroupByField>
                        </GroupByFields>
                    </telerik:GridGroupByExpression>
    More information about grouping you could find here:
    http://www.telerik.com/help/aspnet-ajax/grid-group-by-declarative-definition.html
    http://www.telerik.com/help/aspnet-ajax/grid-group-by-programmatic-definition.html

    I hope this helps.

    Kind regards,
    Radoslav
    the Telerik team
    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 their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Dylan
    Dylan avatar
    8 posts
    Member since:
    May 2013

    Posted 12 Nov 2013 Link to this post

    Using the method you've described, I'm trying to create a separate GroupHeaderTemplate for each grouping level. The code below seemed like the logical thing to do, but the following binding error was thrown on the second GroupHeaderTemplate: 

    'System.Data.DataRowView' does not contain a property with the name 'C01_GARA_PK'.

    <GroupHeaderTemplate>
        <asp:Label ID="lblGroupName" runat="server" Text='<%# Eval("C01_B04_CODE_FK") %>' />
    </GroupHeaderTemplate>
    <GroupHeaderTemplate>
        <asp:Label ID="lblMonth" runat="server" Text='<%# Eval("C01_GARA_PK") %>' />
    </GroupHeaderTemplate>

    To take it a step further, what if I wanted to specify a GroupHeaderTemplate/GroupFooterTemplate for the inside group only... How can I achieve customizable layouts between the independent headers/footers? It seems as though, the headers/footers are only meant to be used in a nonhierarchical scenario.
  5. Marin
    Admin
    Marin avatar
    1044 posts

    Posted 15 Nov 2013 Link to this post

    Hello,

     The grid supports only a single GroupHeader/Footer Template that would be applied on all levels.
    Since the template comprises lots of items it does not hold value of a single field such as:  <%# Eval("C01_B04_CODE_FK") %>'. In the header/footer templates you only have access to the aggregated values (through the AggregateValues collection) in case you have defined aggregates in the grouping.
    More information can be found in the following help topic:
    http://www.telerik.com/help/aspnet-ajax/grid-group-header-footer-templates.html

    Regards,
    Marin
    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.
Back to Top