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

Programmatic Grouping - GroupDescriptor

5 Answers 383 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jacob
Top achievements
Rank 1
Jacob asked on 09 May 2016, 12:43 PM

Hello Telerik,

 

I am trying to pre-group my Gridview on the start of the page (page load)

so i saw a very interesting documentation you have called "programmatic grouping", which has the following block of code i would need to use inside my XAML

<telerik:GroupDescriptor Member="Country"
SortDirection="Ascending"
DisplayContent="Country Group" />

 

My question is: where exactly is this GroupDescriptor? It doesn't seem to recognize the tag at all. Can you provide me a sample or something that uses it? I couldn't find one in your demos tool.

 

thank you.

5 Answers, 1 is accepted

Sort by
0
Jacob
Top achievements
Rank 1
answered on 11 May 2016, 07:19 AM

looking forward to hear from you

thank you!

0
Dilyan Traykov
Telerik team
answered on 11 May 2016, 11:53 AM
Hello Jacob,

I'm attaching a sample project with the two approaches described in the article.

1) The code-behind approach can be placed in the constructor of your Window and be used similarly to:

public MainWindow()
{
    InitializeComponent();
 
    GroupDescriptor descriptor = new GroupDescriptor();
    descriptor.Member = "Name";
    descriptor.SortDirection = ListSortDirection.Ascending;
    this.radGridView.GroupDescriptors.Add(descriptor);
}

2) The same can be achieved using the following XAML code:

<telerik:RadGridView Name="radGridView">
    <telerik:RadGridView.GroupDescriptors>
        <telerik:GroupDescriptor Member="Name" SortDirection="Ascending" />
    </telerik:RadGridView.GroupDescriptors>
</telerik:RadGridView>

I hope you find this helpful.

Regards,
Dilyan Traykov
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
0
Jacob
Top achievements
Rank 1
answered on 11 May 2016, 01:36 PM

This works! But I could swear the telerik:RadGridView.GroupDescriptors tag was not being recognizing before.

anyhow, thank you very much. issue solved!

0
Jacob
Top achievements
Rank 1
answered on 29 Jun 2016, 01:32 PM

Hello again,

For now I just need to change the header of my group on fly

I see it comes after the field's name and as you can see in the attached picture, the header is not very user friendly

How can I change it in the codebehind or viewmodel?

 

Here is the code I use to create the groupdescriptor

private void Page_Loaded(object sender, RoutedEventArgs e)
{
    systemSettingsViewModel = this.DataContext as SystemSettingsViewModel;
    systemSettingsViewModel?.GetAllSystemSettingsDTOs();
    GroupDescriptor descriptor = new GroupDescriptor();
 
    // clear all filters and groupings from an earlier visit!
    CustGridview.ClearFiltersSortingGrouping();
    descriptor.Member = "SettingGroupTranslated";
    descriptor.MemberType = typeof(string);
    descriptor.SortDirection = ListSortDirection.Ascending;
    CustGridview.GroupDescriptors.Add(descriptor);
 
}

0
Dilyan Traykov
Telerik team
answered on 30 Jun 2016, 12:29 PM
Hello Jacob,

You can achieve this by setting the DisplayContent property of the GroupDescriptor as demonstrated in our Programmatic Grouping article:

descriptor.DisplayContent = "Custom Header";

Please let me know if this works for you.

Regards,
Dilyan Traykov
Telerik
Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
Tags
GridView
Asked by
Jacob
Top achievements
Rank 1
Answers by
Jacob
Top achievements
Rank 1
Dilyan Traykov
Telerik team
Share this question
or