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

Custom Sorting with Generic SortDescriptor

2 Answers 256 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Steve
Top achievements
Rank 1
Steve asked on 15 Nov 2019, 04:01 AM

The article about using generic sort descriptor for custom sorting is super unclear

https://docs.telerik.com/devtools/wpf/controls/radgridview/sorting/how-to/generic-descriptor

 

The SortDescriptor<Club, int> returns a simple number that is just the StadiumCapacity of the club, but how do you sort on more complex data using the SortDescriptor or ColumnSortDescriptor? E.g. using a comparison function?

 

We have one column that we want to override the standard sorting, but it's part of a multi-column sorting and we have to be able to load the initial sorting state, so the example of just sorting the item source in the sorting event and then just canceling the even is not sufficient.

 

We also tried deriving from the ColumnSortDescriptor and overriding CreateSortKeyExpression, but it is not clear how to use the parameter expression, or build on the SortKeyExpression created by the base.

2 Answers, 1 is accepted

Sort by
0
Steve
Top achievements
Rank 1
answered on 16 Nov 2019, 12:21 AM
I will add that using the generic SortDescriptor also prevents the sort order numbers from showing on the columns for multi column sorting...
0
Dilyan Traykov
Telerik team
answered on 19 Nov 2019, 04:45 PM

Hello Steve,

To sort the column in a more complex manner, you will need to create the appropriate expression tree. As for your observation, indeed, for the multi-column sorting to be reflected in the UI, the descriptors need to be of type ColumnSortDescriptor.

Thus, the recommended approach, in this case, would be to create a custom ColumnSortDescriptor and override its CreateSortKeyExpression method.

I'm afraid, however, that such custom implementations go out of the scope of the support services we provide. If you require further assistance with generating the required expressions, I can recommend contacting our Professional Services.

If I can, however, further assist you with anything else that does fall within our scope, please let me know.

Regards,
Dilyan Traykov
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
GridView
Asked by
Steve
Top achievements
Rank 1
Answers by
Steve
Top achievements
Rank 1
Dilyan Traykov
Telerik team
Share this question
or