server_side example not connected to front end
server_side example not connected to front end
Hello all,
I have implimented the example: http://www.datatables.net/examples/server_side/server_side.html
only to discover that this example gets all data up front. even if you are paginating. This means that the pagination doesn't actually send any data to the server...so basically...the server_side example is incomplete.
In other words, let's say I have 100 records with pagination enabled and I am using the server side example.
All 100 records load and the backend queries are essentially never called because the UI for the table never sends any query parameters.
I need to know what I'm missing to make this actually send the vars to the PHP. Perhaps somebody could show us a 'working' example?
I have implimented the example: http://www.datatables.net/examples/server_side/server_side.html
only to discover that this example gets all data up front. even if you are paginating. This means that the pagination doesn't actually send any data to the server...so basically...the server_side example is incomplete.
In other words, let's say I have 100 records with pagination enabled and I am using the server side example.
All 100 records load and the backend queries are essentially never called because the UI for the table never sends any query parameters.
I need to know what I'm missing to make this actually send the vars to the PHP. Perhaps somebody could show us a 'working' example?
This discussion has been closed.
Replies
Allan
{"sEcho":1,"iTotalRecords":"5072","iTotalDisplayRecords":10,"aaData":[["The Robert A. Day 4 + 1 BA\/MBA Program, Claremont McKenna College","1","1","yes"],["The Robert A. Day 4 + 1 BA\/MBA Program, Claremont McKenna College","1","1","yes"],["The Robert A. Day 4 + 1 BA\/MBA Program, Claremont McKenna College","1","1","yes"],["The Robert A. Day 4 + 1 BA\/MBA Program, Claremont McKenna College","1","1","yes"],["The Robert A. Day 4 + 1 BA\/MBA Program, Claremont McKenna College","1","1","yes"],["Robert A. Day 4 Plus 1 Program, Claremont McKenna College","1","1","yes"]]}
Note the iTotalDisplayRecords value of '10'. The records are loading into the table and the table is displaying all 5000 records....
Ideas?
The JSON itself is only returning 10 records, for an iTotalDisplayRecords of 10.
Yes, that's correct.
>>The JSON itself is only returning 10 records, for an iTotalDisplayRecords of 10.
No, my json string contains 5072 records...
The example I posted is a subset.
Allan
var url = "../services/getPageRecords.php";
$('#content_table').dataTable({
"bProcessing": true,
"bServerSide": true,
"bFilter":true,
"bLengthChange": true,
"bPaginate": true,
"bSort": true,
"iDisplayLength": 10,
"sAjaxSource": url,
"oTableTools": {
"sSwfPath": "../plugins/datatable/copy_cvs_xls_pdf.swf"
},
"fnServerData": function (sSource, aoData, fnCallback)
{
$.ajax({
"url": url,
"data": data,
"success": function(json)
{
fnCallback(json);
},
"dataType": "json",
"cache": false,
"error": function(xhr, error, thrown)
{
if (error == "parsererror")
{
//error(thrown);
alert('Error ' + error);
}
}
});
},
"sPaginationType": "full_numbers",
"sDom": 'T<"clear">lfrtip'
});
If I'm understanding Allan's explanation correctly, this is the expected behaviour, so I'm at a loss for explaining why your iTotalDisplayRecords would only be 10 without filtering.