I am implementing sorting (Order by) for dataTable at server side. All sessms to be fine Even my data gets properly sorted (I can check that in firebug.). Now the problem is , datatable is not getting reloaded after that, and “processing…” continues to appear. Any clue on where to write function for reload. I know it can be done by
oTable.fnDraw(true);
but I dont know where to write it after header is clicked for sorting. Let me know if you need any code snippet to debug.
Edit1**
I am not able to reload table even after using global search, or changing no. of rows to display. Any idea why this is happening???
var oTable = $('#datatable').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "datatableprocessor",
"sPaginationType": "full_numbers",
"fnRowCallback": function (nRow, aData, iDisplayIndex) { return nRow; },
"fnServerData": function ( sSource, aoData, rfrshCallbk ) {
$('.search').each(function(index) {
var name = $(this).attr("name");
var tempName = name.replace("search","condition" );
var condition = $("[name='"+tempName+"']").val();
var value = $(this).val();
aoData.push({ "name": name, "value": value+""+condition });
});
aoData.push({ "name": "queryId", "value": "test" });
$.ajax( {
"dataType": 'json',
"type": "POST",
"url": sSource,
"data": aoData,
"success": rfrshCallbk
} );
},
"aoColumnDefs": [
{ "sName": "c.id", "aTargets": [ 0 ] },
{ "sName": "c.firstname", "aTargets": [ 1 ] },
{ "sName": "c.lastname", "aTargets": [ 2 ] },
{ "sName": "c.telephone", "aTargets": [ 3 ] }
]
} );//
Edit 2 —–
I tried to check if the Json comming is correct, so to debug I changed code to
"success": function(json){
alert(JSON.stringify(json));
rfrshCallbk(json);
}
In both cases , when I reload my page or do sorting json string is same .. ??!!?? don’t know what is wrong ??!!??
I got the solution, I havent implemented “”sEcho and was every time sending back “sEcho” as “1”, that was warding me from getting a refreshed list.