is it possible to change default starting sort direction of Grid from ASC to DESC?
Thanks,
Yuriy
Dimiter Topalov
Telerik team
commented on 09 Feb 2018, 09:20 AM
Hello Yuriy,
You can specify the default initial sorting direction (and field the data will be sorted by) of the Grid by binding the "sort" input to the desired array of Sort descriptors, e.g.:
Thanks for the quick reply.
It's not exactly what I want. My task:
1. Grid's initial load is without any sorting
2. When user initiates sorting from any column header the direction is DESC
Thanks,
Yuriy
1 Answer, 1 is accepted
0
Dimiter Topalov
Telerik team
answered on 12 Feb 2018, 11:41 AM
Hello Yuriy,
Thank you for the clarification about the desired behavior. The only way to achieve it via the built-in Grid sorting functionality (i.e. via modifying the Sort descriptors, based on some custom logic) would be to sacrifice the allow unsort functionality (i.e. once the Grid is sorted by some field, further sorting will yield either ascending or descending direction, not "unsorted" or the initial state), e.g.:
This is due to the fact that the default sorting direction "cycle" of the Grid is (starting from an initial unsorted state): 'asc' --> 'desc' --> 'unsorted' --> 'asc'...
There is no reliable way to both switch the direction to 'desc' when it is 'asc' and vice versa, because the incoming descriptor after the direction is switched to 'desc' will contain 'undefined' for the direction (if the default allow unsort functionality is enabled) and the next value will be 'asc'... but we are programmatically switching 'asc' to 'desc', so 'desc' will never arrive as a sort descriptor info in the sortChange event and thus we are unable to switch it to 'asc'. This is why if we need to reverse the built-in Grid sorting order, we will have to sacrifice the allow unsort functionality. I hope this makes sense.
That said, if you have the time, please submit a feature request to our UserVoice portal for any features and enhancements (like the desired customized Grid sorting functionality) that you would like to see as a built-in configurable feature in a future version of our packages:
You can specify the default initial sorting direction (and field the data will be sorted by) of the Grid by binding the "sort" input to the desired array of Sort descriptors, e.g.:
https://plnkr.co/edit/ViZf3yKbe4NdQ876dST0?p=preview
I hope this helps.
Regards,
Dimiter Topalov
Progress Telerik
Hi Dimiter,
Thanks for the quick reply.
It's not exactly what I want. My task:
1. Grid's initial load is without any sorting
2. When user initiates sorting from any column header the direction is DESC
Thanks,
Yuriy