override default sort
override default sort
I am not having luck overriding the default sort - the table is sorting asc on the first column. Here is my initialization code.
oTable = $('#example').dataTable( {
"bProcessing": true,
"sAjaxSource": "/cfc/canuhelp.cfc?method=osearch&returnformat=json",
"fnServerParams": function ( aoData ) {
aoData.push( { "name": "OU", "value": "o" } );
},
"sAjaxDataProp": "DATA",
"aoColumnDefs": [
{ "asSorting": [ "desc" ], "aTargets": [6] }
]
});
oTable = $('#example').dataTable( {
"bProcessing": true,
"sAjaxSource": "/cfc/canuhelp.cfc?method=osearch&returnformat=json",
"fnServerParams": function ( aoData ) {
aoData.push( { "name": "OU", "value": "o" } );
},
"sAjaxDataProp": "DATA",
"aoColumnDefs": [
{ "asSorting": [ "desc" ], "aTargets": [6] }
]
});
This discussion has been closed.
Replies
oTable.fnSort( [ [6,'desc'] ] );
to force the 7th column to be sorted descending.
so which is best practice trying to use the column definitions or using the function?