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

Remove footer for nested groups

2 Answers 145 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Dmitriy
Top achievements
Rank 1
Dmitriy asked on 21 Jul 2016, 06:24 PM

In my RadGridView I group data by two columns: first by column1 and then by column2. When I set ShowGroupFooters="true" I end up with two footers - one for column1 and another for column2. How can I hide footers for the nested groups (over column2) and leave only footers for the groups over column1?

thank you

2 Answers, 1 is accepted

Sort by
0
Dilyan Traykov
Telerik team
answered on 25 Jul 2016, 12:09 PM
Hello Dmitriy,

The desired behavior can be achieved by the use of RadGridView's GroupFooterRowStyleSelector property. Here is how you can define it:

public class GroupFooterRowStyleSelector : StyleSelector
{
    public override Style SelectStyle(object item, DependencyObject container)
    {
        IGroup group = item as IGroup;
 
        if (group != null)
        {
            if (group.ParentGroup != null)
            {
                return NestedGroupStyle;
            }
            else
            {
                return NormalGroupStyle;
            }
        }
 
        return null;
    }
 
    public Style NestedGroupStyle { get; set; }
    public Style NormalGroupStyle { get; set; }
}
<my:GroupFooterRowStyleSelector x:Key="GroupFooterRowStyleSelector">
    <my:GroupFooterRowStyleSelector.NestedGroupStyle>
        <Style TargetType="telerik:GridViewGroupFooterRow">
            <Setter Property="Visibility" Value="Collapsed"/>
        </Style>
    </my:GroupFooterRowStyleSelector.NestedGroupStyle>
    <my:GroupFooterRowStyleSelector.NormalGroupStyle>
        <Style TargetType="telerik:GridViewGroupFooterRow">
            <Setter Property="Visibility" Value="Visible" />
        </Style>
    </my:GroupFooterRowStyleSelector.NormalGroupStyle>
</my:GroupFooterRowStyleSelector>

<telerik:RadGridView GroupFooterRowStyleSelector="{StaticResource GroupFooterRowStyleSelector}" />

Please let me know if such an approach would work for you.

Regards,
Dilyan Traykov
Telerik by Progress
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Dmitriy
Top achievements
Rank 1
answered on 25 Jul 2016, 09:13 PM

It works great.

 

Thank you,
Dmitriy

Tags
GridView
Asked by
Dmitriy
Top achievements
Rank 1
Answers by
Dilyan Traykov
Telerik team
Dmitriy
Top achievements
Rank 1
Share this question
or