Remove footer for nested groups

3 posts, 0 answers
  1. Dmitriy
    Dmitriy avatar
    3 posts
    Member since:
    May 2012

    Posted 21 Jul Link to this post

    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. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    371 posts

    Posted 25 Jul Link to this post

    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.
  3. UI for WPF is Visual Studio 2017 Ready
  4. Dmitriy
    Dmitriy avatar
    3 posts
    Member since:
    May 2012

    Posted 25 Jul in reply to Dilyan Traykov Link to this post

    It works great.

     

    Thank you,
    Dmitriy

Back to Top