Restrict three levels of sorting
Restrict three levels of sorting
binit
Posts: 5Questions: 2Answers: 0
Hi,
I am using DataTables 1.10.13
I need to restrict the sorting to only three columns,
i.e. if i click three columns then i click the column no 4 the only that particular column needs to be sorted the previous three sorted columns sorting needs to be removed.
Thanks.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
DataTables multi-column sorting doesn't have a limit. If you press shift while clicking a header cell to sort, it will add that column to the existing sort. If you don't press shift, it will sort that column only.
Allan
Thanks Allan,
But,I found a way to do the same i.e.restricting to sort only three columns at a time and reset the sort when fourth column is selected.
Thanks.
How did you do it? An event listener on the
order
event?Allan
Hi Allan,
Firstly I added _fnSortListener( settings, colIdx, true, callback );
instead of
_fnSortListener( settings, colIdx, e.shiftKey, callback );
which would sort on click of the header always.
Then in the _fnSortListener function
in condition bSortMulti i added another if condition which is
Awesome - thanks!
Allan