Dynamic multicolumn sorting - fnPreDrawCallback

Dynamic multicolumn sorting - fnPreDrawCallback

djpnodjpno Posts: 1Questions: 1Answers: 0

Hi,

I have a table with 3 columns and when I sort column 1 or 2 then I would like to sort column 3 by descending.

I'm using fnPreDrawCallback (I tried to use fnDrawCallback too). Here is my code:

"fnPreDrawCallback": function (oSettings) {
    var column = oSettings.aaSorting[0][0];
    if (column !== 3) {
        oSettings.aaSorting.push([3, "desc"]);
    }
}

This code looks fine, but, for example, when I sort column 1, the column 3 isn't sorted and, more awkward, when I try to sort at a 2nd time on column 1, the sort result is always ascending.

How can I achieve this?

This discussion has been closed.