Hi
I have a request to change the behaviour of the sorting feature on our grids.
What the user would like is to have the following behaviour:
rather than having to press shift click.
What would be the recommended approach to achieve this?
Regards
Aidan
Hello,
I'm just following up to see if the suggested helped or if you have any other questions on the matter.
This should work for 14.2:
columnSorting: function (evt, ui) { if((ui.owner.option("firstSortDirection") == ui.direction) && ui.owner.grid.dataSource.settings.sorting.expressions.length != 0) { var i, se = [], exprs = ui.owner.grid.dataSource.settings.sorting.expressions; for (i = 0; i < exprs.length; i++) { se.push(exprs[i].fieldName) } for (i = 0; i < se.length; i++) { ui.owner.unsortColumn(se[i], undefined) } return false; }}
Please test it in your app and let me know if you have further questions, I will be glad to help.
Hi Hristo,
Thanks for the reply.
Sorry forgot to add the platform info, we are on 14.2 with plan to move to 15.1 but not immediately. If you have a solution for 14.2 that would be great.
Hi Aidan,
You can use the firstSortDirection property and then handle the columnSorting event. The whole code will look like this:
features: [ { name: "Sorting", firstSortDirection: "descending", columnSorting: function (evt, ui) { if((ui.owner.option("firstSortDirection") == ui.direction) && ui.owner.grid.dataSource.settings.sorting.expressions.length != 0) { ui.owner.clearSorting(); return false; } } }
This code will execute when user tries to sort a column for third time as the provided scenario. The clearSorting method removes the current sorting(for all sorted columns) and updates the UI.
Please be aware that this will only work for 15.1. Let me know if you use lower version of IgniteUI so that I can modify my code accordingly.