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

Nested Grouping- Managing subheader layouts

1 Answer 45 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dylan
Top achievements
Rank 1
Dylan asked on 13 Nov 2013, 05:23 PM
I have a radgrid that uses nested groups by specifying two GridGroupByExpressions on the front-end. Unfortunately, I cannot find an effective way to apply separate GroupHeaderTemplates to each group level. Here's what I've tried:

<GroupByExpressions>
    <telerik:GridGroupByExpression>
        <SelectFields>
            <telerik:GridGroupByField FieldName="GroupName" />
        </SelectFields>
        <GroupByFields>
            <telerik:GridGroupByField FieldName="GroupName" SortOrder="Ascending" />
        </GroupByFields>
    </telerik:GridGroupByExpression>
    <telerik:GridGroupByExpression>
        <SelectFields>
            <telerik:GridGroupByField FieldName="Date" FormatString="{0:MMMM yyyy}" />
        </SelectFields>
        <GroupByFields>
            <telerik:GridGroupByField FieldName="Date" SortOrder="Ascending" />
        </GroupByFields>
    </telerik:GridGroupByExpression>
</GroupByExpressions>
<GroupHeaderTemplate>
    <asp:Label ID="lblGroupName" runat="server" Text='<%# Eval("GroupName") %>' />
</GroupHeaderTemplate>
<GroupHeaderTemplate>
    <asp:Label ID="lblDate" runat="server" Text='<%# Eval("Date") %>' />
</GroupHeaderTemplate>

The GroupByExpressions work just fine, but when I try to add the GroupHeaderTemplates, the following exception is thrown on the second GroupHeaderTemplate: "'System.Data.DataRowView' does not contain a property with the name 'Date'." If I remove the second one, both groups are given the same template (e.g. the nested Date group displays the current GroupName). Is there a way to manage group headers and group subheaders independently?

1 Answer, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 18 Nov 2013, 11:02 AM
Hello Dylan,

When you set multiple GroupHeaderTemplate, only the last one will be taken into account. 

For handling different group headers you should use the approach shown in our online help article "Group Header and Footer Templates". As you will see, the visible property of the labels depends on the current group header. Thus will allow you to get the desired result.

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
Grid
Asked by
Dylan
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
Share this question
or