Always sorted

1 Answer 85 Views
Grid
Robert
Top achievements
Rank 1
Iron
Veteran
Robert asked on 30 Nov 2021, 02:13 PM | edited on 30 Nov 2021, 02:15 PM

When clicking the header of a sortable column, it toggles between ascending, descending and no sort order.
How to make it always have a sort order, i.e. only toggle between ascending and descending?

1 Answer, 1 is accepted

Sort by
0
Hristian Stefanov
Telerik team
answered on 03 Dec 2021, 11:01 AM

Hi Robert,

You can achieve that kind of custom sorting by using the Grid state. Use the OnStateChanged and choose to always have the desired sort descriptor. You will have to cache the old state and compare which column lost their sort state.

One thing to mention is - if there is always a sort parameter, the underlying SQL query will become very heavy. Every column will always have an OrderBy statement. That can make performance worse on the backend.

I hope this helps. Let me know if you need further information.

Regards,
Hristian Stefanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Tags
Grid
Asked by
Robert
Top achievements
Rank 1
Iron
Veteran
Answers by
Hristian Stefanov
Telerik team
Share this question
or