How to remove shift-key requirement for multicolumn sorting?

How to remove shift-key requirement for multicolumn sorting?

frankyyfrankyy Posts: 9Questions: 5Answers: 0

In any multi-column datatables.net table, multi-column sorting normally requires clicking a header to set the initial sort, then using “Shift + left-click“ on another header to add it to the existing sort order. I want to override this behavior so that the “Shift + left-click” functionality works without requiring the Shift key. How can I override this behaviour?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 65,397Questions: 1Answers: 10,858 Site admin
    edited December 3 Answer ✓

    With the build in click to sort listener, there is no option to disable that behaviour (this is the code in question). The reason for that is that if it added the next column to the existing sort, there would be no way to order by just the target column on its own!

    Two options:

    1. Add your own sort listener and use order() to order the table (use ordering.handler to disable the build in listener).
    2. Use ColumnControl's ordering buttons to provide ordering control without needing a keyboard.

    Allan

Sign In or Register to comment.