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
looking forward to hear from you
thank you!
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
This works! But I could swear the telerik:RadGridView.GroupDescriptors tag was not being recognizing before.
anyhow, thank you very much. issue solved!
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);}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