Default sort not working with either method
Default sort not working with either method
jpretorius
Posts: 2Questions: 0Answers: 0
I'm trying to use asSorting in aoColumnDefs to set the default sort order when the page loads, but for some reason it isn't working. With that not working I also tried to use asSorting in aoColumns and that didn't work either. For some reason when the page first loads the first column is sorted in ascending order.
By the way, I've tried to use aTargets of 0, 1 and _all without a change in behaviour. I've also tested multiple browsers.
Can anyone help me figure this one out?
My initialising code is as follows:
[code]
$(document).ready(function() {
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"iDisplayLength": 100,
"sAjaxSource": "scripts/server_processing.php",
"fnServerParams": function ( aoData ) {
aoData.push( { "name": "sTable", "value": "audit" } );
aoData.push( { "name": "sIndexColumn", "value": "idaudit" } );
aoData.push(
{ "name": "aColumns[]", "value": "datetime" },
{ "name": "aColumns[]", "value": "action" },
{ "name": "aColumns[]", "value": "detail" }
);
},
"oLanguage": {
"sLengthMenu": 'Display '+
'100'+
'250'+
'500'+
'All'+
' entries per page'
},
"aoColumnDefs": [
{ "asSorting": [ "desc", "asc" ], "aTargets": [ 0 ] }
],
"aoColumns": [
{ "asSorting": [ "desc", "asc" ] },
null,
null
]
} );
} );
[/code]
By the way, I've tried to use aTargets of 0, 1 and _all without a change in behaviour. I've also tested multiple browsers.
Can anyone help me figure this one out?
My initialising code is as follows:
[code]
$(document).ready(function() {
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"iDisplayLength": 100,
"sAjaxSource": "scripts/server_processing.php",
"fnServerParams": function ( aoData ) {
aoData.push( { "name": "sTable", "value": "audit" } );
aoData.push( { "name": "sIndexColumn", "value": "idaudit" } );
aoData.push(
{ "name": "aColumns[]", "value": "datetime" },
{ "name": "aColumns[]", "value": "action" },
{ "name": "aColumns[]", "value": "detail" }
);
},
"oLanguage": {
"sLengthMenu": 'Display '+
'100'+
'250'+
'500'+
'All'+
' entries per page'
},
"aoColumnDefs": [
{ "asSorting": [ "desc", "asc" ], "aTargets": [ 0 ] }
],
"aoColumns": [
{ "asSorting": [ "desc", "asc" ] },
null,
null
]
} );
} );
[/code]
This discussion has been closed.
Replies
I think you want aaSorting - that specifies the initial sort and is independent of the asSorting parameters for the columns.
Allan