I am attempting to have the user click on a column header and based on other factors sort specific columns. In other words, have the user click column 5 and through if statements sort column 1 or 2 then column 5.
So I'm using,
.on('order.dt', function (e){})
to capture the order event. I then go through my if statements and then use,
table.order([1,"asc"],[5,"asc"]).draw();
This works as expected, the table is sorted by column 1 then by column 5, asc. The arrow on both columns show that they're being sorted in asc order.
The issue that I am facing happens when you then click on those columns after the above.
If I click on column 1 (which is going to change it to desc order) and run
table.order();
it gives me the correct two element array with 1, "desc" as the contents.
However, if I click on column 5 instead (which should change it to desc order) and run
table.order();
it gives me the incorrect two element array with 5, "asc" as the contents.
Similarly, if I used
table.order([1,"asc"],[5,"asc"],[6,"asc"]).draw();
Column 1 would show it correctly as desc whereas column 5 and 6 would show incorrectly as asc.
Is it doing this because after the first sorted column it isn't truly sorted asc - just asc based on the first column?
Is there a way around having it always come up that way? As of right now if I used the order given,
table.order([1,"asc"],[table.order()[0][0],table.order()[0][1]]).draw();
it will always come up as asc.