Preserve multi-column sort when sorting?

Preserve multi-column sort when sorting?

daan.timmerdaan.timmer Posts: 4Questions: 0Answers: 0
edited January 2011 in General
Right, I've got a table that looks like this:

[col0 (name)] - [col1 (key)] - [some more] - [col7 (order)]

I initialise the table using:

[code]var faq = {
table : null,

init : function( ){
faq.table = $("table.display").dataTable({
sPaginationType: "full_numbers",
iDisplayLength: 25,
bStateSave: true,
"oLanguage": {
"sUrl": "/jquery/addons/datatable/lang/{\literal}{$language}{literal}"
},
"aaSorting" : [[0,"asc"], [1,"asc"], [7, "asc"]],
"aoColumns" : [
null, //0
null, //1
{"bSortable" : false}, //2
{"bSortable" : false}, //3
{"bSortable" : false}, //4
{"bSortable" : false}, //5
{"bSortable" : false}, //6
null, //7
{"bSortable" : false}, //8
]
});
}
}[/code]

I would like column 0 to be the "first/master" sort column, column 1 should be second and 7th column should be 3th.

However, atm, when you click on, say column 7, column 0 and 1 will be un-sorted, which I don't want to happen. Sorting on column 7 should also keep on sorting column 0 and 1.

I know it is supposed to be done by holding shift. But that is not feesable in this situation. It should multi-sort on column0,1,7 shift or not.

I removed most of the "faq" code because it is not needed anyway.

Replies

  • daan.timmerdaan.timmer Posts: 4Questions: 0Answers: 0
    No clue anyone?
  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    aaSortingFixed ( http://datatables.net/usage/options#aaSortingFixed ) will let you force the sorting, while allowing the user to sort as well (aaSortingFixed is always use first). If you want to sort initially like that, and disallow the user for clicking then just unbind the click() functions from the TH elements.

    Allan
This discussion has been closed.