RadGridView sorting/filtering within groups

0 Answers 53 Views
GridView
Oleh
Top achievements
Rank 1
Oleh asked on 22 Jun 2022, 02:53 PM

Hello,

Is it possible to sort/filter data only within a specified group?

For example, there are 3 groups, the first one is sorted by the first column, the second group is sorted by the second column and etc. 

Dilyan Traykov
Telerik team
commented on 27 Jun 2022, 08:16 AM

Hello Oleh,

You will need to implement custom sorting to achieve this requirement by using one of the approaches from this article: Custom Sorting.
Oleh
Top achievements
Rank 1
commented on 29 Jun 2022, 10:55 AM | edited

Thank you for the answer.
I've looked into the article, and I'm not sure that I understand how to achieve the requirement, following the article's contents.
Can you pinpoint me in the right direction? 

The issue is that I have to implement the possibility to change the group's sorting settings in run-time.

For example, I have a data model - Car, with properties: model (string), speed (double), price (decimal), and type (enum - normal, sport). I've grouped the grid by the type. As a result, the grid has two groups: normal and sports cars. In run-time, I want to sort the normal cars' group by ascending price, and then the sports cars' group by descending speed, while having the ability to change the sorting settings of each group in real-time. 

As I see it, the groups have to have their own sort descriptors, that could be modified.

Some signs of the needed functionality I saw in generic group descriptors (grouping expression), but it seems the sorting there is for the groups' order in the grid, not the items in a particular group.

Dilyan Traykov
Telerik team
commented on 04 Jul 2022, 09:20 AM

Hello Oleh,

Thank you for the clarification.

My suggestion at this point would be to handle the Sorting event and manually update the ItemsSource of the RadGridView control based on the conditions.

To demonstrate what I have in mind, I've prepared a small sample project to demonstrate what I have in mind. If you sort by any of the columns, you will notice that the items in the groups are sorted by the following criteria - for the GK and DF positions the players are sorted by their Number and in the MF and FW positions, the items are sorted by their Country property.

You can use a similar approach to sort the groups in your original application. I hope you find the attached sample project helpful in the process.

No answers yet. Maybe you can help?

Tags
GridView
Asked by
Oleh
Top achievements
Rank 1
Share this question
or