2) Group on a column
3) set the collection to a new empty collection, or set grid itemssource = null
You should notice that the columns are still on the grid, but the group is removed.
We are trying to persist grouping options across different sets of data, when hitting an empty dataset, the grouping is lost.
The _Grouped and _Grouping events are not fired, however a manual check shows that the GroupDescriptors are indeed cleared.
(This is using Q3 Beta but it was the same behaviour in previous versions)
11 Answers, 1 is accepted
This is by design. You can save the group descriptors somewhere before resetting the data and add them to the GroupDescriptors collection after the data has come.
All the best,
Veselin Vasilev
the Telerik team
Marty
When the ItemsSource of a RadGridView is changed, there is no guarantee that the columns and descriptors defined will be applicable to the type of the new data items. That is why, rather than risking exceptions in the LINQ runtime, they are cleared.
Greetings,
Yavor Georgiev
the Telerik team
By calling the Collection<T>.Clear method of the respective collection.
Kind regards,Rossen Hristov
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.
Thank you for sharing your feedback.
Regards,
Dimitrina
Telerik
Hi guys, doesn't seem like telerik was much help on this at all. I encountered the same issue in my project where I was setting the ColumnGroupDescriptor of a RadGrid GroupDescriptor through my XAML. At some point the screen would rebind the RadGrid to null and then back to a valid list. At this point my grouping was completely lost.
I hate programatically setting binding but in this instance, I passed the RadGrid to my ViewModel as a method parameter from a trigger event and in the corresponding method linked to that trigger, I set the itemsource and a new GroupDescriptor. This worked and allowed the grouping to reappear each time the Grid was set to null and then back to a list.I had to remove the GroupDescriptor definition in the XAML as well.
Sample of C# code to set Group Descriptor Programatically:
GroupDescriptor descriptor = new GroupDescriptor();
descriptor.Member = "NAME_OF_MY_COLUMN";
descriptor.SortDirection = ListSortDirection.Ascending;
thisAllocationGrid.GroupDescriptors.Add(descriptor);
This is a bug. Plain and simple.
XAMLdefines the Grouping/Filtering. If the 'new' Item source has a different shape then ofcourse there should be an exception.
The real reason Telerik do not want to change this behaviour is backwards compatibility, which is totally understandable.
Like Shawn, I have moved all XAML definitions of group/filtering to the ViewModel where I build the QueryableCollectionView. Thumbs down.
Run into this, too. found a work around in an other thread:
Hello Carsten,
I'm happy to hear that you've found a suitable solution and would like to thank you for sharing it with our community.
Should you require any further assistance, please let us know.
Regards,
Dilyan Traykov
Progress Telerik
Five days of Blazor, Angular, React, and Xamarin experts live-coding on twitch.tv/CodeItLive, special prizes, and more, for FREE?! Register now for DevReach 2.0(20).