DataGrid GroupHeader indent based on level

2 Answers 80 Views
DataGrid
Clint
Top achievements
Rank 1
Iron
Iron
Iron
Clint asked on 24 Oct 2023, 05:05 PM
I need to implement an indent for the group headers based on level to better show the hierarchy. Is there anything built-in for this or a recommended method? The only thing I can see to do would be to create a converter to read the level of the GroupHeader and set the margin property of it based on that value.

2 Answers, 1 is accepted

Sort by
0
Didi
Telerik team
answered on 27 Oct 2023, 11:55 AM

Hi Clint, 

The DataGrid does not provide this built-in. I have logged it as a feature request here: https://feedback.telerik.com/maui/1628958-datagrid-indent-groupheader-based-on-its-level 

For now the option is to use a converter.

Regards,
Didi
Progress Telerik

A brand new .NET MAUI course was just added to the Virtual Classroom. The training course is developed to help you get started with the Telerik UI for .NET MAUI components and features. It aims to put you in the shoes of an engineer who adds new features to an existing application. You can check it out at https://learn.telerik.com
0
Clint
Top achievements
Rank 1
Iron
Iron
Iron
answered on 26 Nov 2023, 01:28 PM

Here's what I used as a solution.

In XAML:

                    <telerik:RadDataGrid.GroupHeaderTemplate>
                        <DataTemplate x:DataType="gridContext:GroupHeaderContext">
                            <Grid Margin="{Binding Level, Converter={StaticResource GroupHeaderIndentConverter}}">

 

My converter:

    public class GroupHeaderIndentConverter : IValueConverter   
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is int groupLevel)
            {
                return new Thickness(groupLevel * 10, 0, 0, 0);
            }
            return new Thickness(0);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }

Tags
DataGrid
Asked by
Clint
Top achievements
Rank 1
Iron
Iron
Iron
Answers by
Didi
Telerik team
Clint
Top achievements
Rank 1
Iron
Iron
Iron
Share this question
or