How do I implement grouping and sorting on multiple fields

1 Answer 268 Views
ListView
ward
Top achievements
Rank 1
ward asked on 26 Jul 2022, 08:50 AM | edited on 26 Jul 2022, 08:58 AM
Hi,

I want to get the data through the viewmodel, sort the data multiple times, and render to the ui correctly according to the order of the data.

can i do it?

the code please refer to images.

eg: Grouping by Index,and OrderBy Index,Then Orderby Country.

thanks.

1 Answer, 1 is accepted

Sort by
0
Antoan
Telerik team
answered on 28 Jul 2022, 03:09 PM

Hello Ward,

Thank you for the provided images.

Indeed you can sort the data multiple times. You can use the SortOrder property to define whether you want the items in descending or ascending order.

To sort the items inside a group you can use the following code:

 

<telerik:RadListView.SortDescriptors>
           <telerik:ListViewPropertySortDescriptor PropertyName="Name" SortOrder="Descending"/>
 </telerik:RadListView.SortDescriptors>

 

To sort the groups of the ListView use the following code:

 

<telerik:RadListView.GroupDescriptors>
        <telerik:ListViewPropertyGroupDescriptor PropertyName="Index" SortOrder="Descending"/>
</telerik:RadListView.GroupDescriptors>

 

For more detailed information about sorting go to the following link leading to our ListView Sorting documentation: 
https://docs.telerik.com/devtools/maui/controls/listview/sorting 

For more details about group sorting follow the link leading to our ListView Grouping documentation:
https://docs.telerik.com/devtools/maui/controls/listview/grouping/property-group-descriptor#propertygroupdescriptor 

I hope the provided information helps.

Regards,
Antoan
Progress Telerik

The Premier Dev Conference is back! 

Coming to you live from Progress360 in-person or on your own time, DevReach for all. Register Today.


Tags
ListView
Asked by
ward
Top achievements
Rank 1
Answers by
Antoan
Telerik team
Share this question
or