Record order changes by performing sort on multiple columns consecutively.
Record order changes by performing sort on multiple columns consecutively.

On this example http://live.datatables.net/
- Sort on name in descending order and then on office in descending order : 1st record is Zorita Serrano
- Sort on salary in descending order and then on office in descending order : 1st record is Gavin Cortez and 2nd is Zorita Serrano.
I have a use case when I want to have Zorita Serrano as 1st record when I sort on office column, no matter how many sorts I do previously.
What the option/implementation to have consistent grouping / ordering of records?
Thanks
Ankur Dohare
This discussion has been closed.
Answers
Are you saying that you always want the name column sorted descending? If so then
orderFixed
is what you want to use. Or possibly the solution presented in this blog.Kevin
Applying order fixed has not worked for this usecase. Is there any way I can clear order before sort is applied and the draw.
I get into an infinite loop if I capture order event and apply draw inside it. Obviously. But clearing order before draw will solve the usecase.
That will cause a loop since
draw()
updates the table order causing theorder
to fire.I'm not clear on what you want to do. There is not a built-in way to force
Zorita Serrano
in the Name column to the top when sorting by other columns. Maybe you can use a hidden column that as the value of1
for the row withZorita Serrano
and0
for the remaining rows. Then usingorderFixed
you can always sort by that hidden column.Kevin