Unable to stop initial sorting
Unable to stop initial sorting
I am using datatables 1.10.7.
I want to disable the initial sort that datatables does automatically.
Datatables refuses to listen to
"aaSorting": []
or even this
"aaSorting": [[0,'desc'],[1,'desc']]
It sorts by the first column in the table in ASC order. The only way to stop this is to use
"bSort": false
however that removes all sorting functionality on my table.
My table works 100% for everything else except sorting. Filtering, searching, pagin etc works 100%. When I set
"bSort" : true
or, when I leave it out, as I believe the default is true,
I get the following error:
"error":"An SQL error occurred: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'ORDER BY `column1` ASC\n\t\t\t LIMIT 0, 10' at line 4"
I have tried with and without aaSorting, with and without bSort and mixing them together in various ways.
Any help ?
PS, here is my table definitions:
oTable = $('#table_demo').DataTable(
{
"bSort": true,
"aaSorting": [[0,'desc'],[1,'desc']],
"bJQueryUI": true,
"bPaginate": true,
"bStateSave": true,
"processing": true,
"serverSide": true,
"sPaginationType": "full_numbers",
"ajax":
{
"url": "view_demo_remote.php",
"data":
{
"field1": "".$_SESSION['field1']."",
"field2": "".$_SESSION['field2']."",
"field3": "".$_SESSION['field3'].""
}
},
"columns":[
{ "bSortable": true, "data": "col1" },
{ "bSortable": true, "data": "col2" },
{ "bSortable": true, "data": "col3" },
{ "bSortable": false, "data": "col4" },
{ "bSortable": false, "data": "col5" },
{ "bSortable": false, "data": "col6" }
],
"fnCreatedRow": function( nRow, aData, iDataIndex )
{
$(nRow).attr("attrname",aData["col1"]);
},
"fnDrawCallback": function( oSettings )
{
}
});
EDIT:
I also tried using this from the latest api , but with no success:
"order": []
Answers
I managed to solve the problem. Thanks to my stack overflow question being answered here http://stackoverflow.com/questions/30754110/unable-to-stop-initial-sorting-using-datatables/30756837#30756837 .
The problem is that I cannot have ORDER information in the where clause that I pass to the complex SSP method on the server side script.
Someone please mark this thread as SOLVED.