pagination ('NExt/Previous') not created
pagination ('NExt/Previous') not created
hi,
I'm getting data from server side (PHP creates JSONP) and I need pagination (using 'next' and 'previous' page). The pagination by '10', '20 records'... works fine.
$sLimit is defined by default in my PHP as 10. So, by default pagination is not possible (shows only 10 results). If i remove $sLimit I get all records (which is not the desired behaviour as I see in examples)
iDisplayLength is only useful for the first page I think (and imposes a limit in the SQL again).
I checked the API and examples, without success... i'm missing something, for sure! but in all the examples no special parameter is defined... just everything goes fine.
Thanks in advance!
Some code...
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "http://localhost:8888/server_processing_pgsql2.php?info=institutions",
"fnServerData": function( sUrl, aoData, fnCallback ) {
$.ajax( {
"url": sUrl,
"data": aoData,
"success": fnCallback,
"dataType": "jsonp",
"cache": false
} );
A generated JSONP example
jQuery16108984647200691713_1311934869725({"sEcho":1,"iTotalRecords":5,"iTotalDisplayRecords":5,"type":"institutions","ids_to_hide":["0"],"aaData":[["127","Zoo-Parc de Tr\u00e9gomeur","parc zoologique","Tr\u00e9gomeur"],["142","Zoodyss\u00e9e","parc zoologique","Villiers en Bois"],["139","Zoo de l'Orangerie","parc zoologique","Strasbourg"],["141","Zoo de Jurques","parc zoologique","Jurques"],["125","Zoo d'Attilly","parc zoologique","Ozoir-la-Ferriere"]],"ids":[],"new":[["127"],["142"],["139"],["141"],["125"]]});
I'm getting data from server side (PHP creates JSONP) and I need pagination (using 'next' and 'previous' page). The pagination by '10', '20 records'... works fine.
$sLimit is defined by default in my PHP as 10. So, by default pagination is not possible (shows only 10 results). If i remove $sLimit I get all records (which is not the desired behaviour as I see in examples)
iDisplayLength is only useful for the first page I think (and imposes a limit in the SQL again).
I checked the API and examples, without success... i'm missing something, for sure! but in all the examples no special parameter is defined... just everything goes fine.
Thanks in advance!
Some code...
$('#example').dataTable( {
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "http://localhost:8888/server_processing_pgsql2.php?info=institutions",
"fnServerData": function( sUrl, aoData, fnCallback ) {
$.ajax( {
"url": sUrl,
"data": aoData,
"success": fnCallback,
"dataType": "jsonp",
"cache": false
} );
A generated JSONP example
jQuery16108984647200691713_1311934869725({"sEcho":1,"iTotalRecords":5,"iTotalDisplayRecords":5,"type":"institutions","ids_to_hide":["0"],"aaData":[["127","Zoo-Parc de Tr\u00e9gomeur","parc zoologique","Tr\u00e9gomeur"],["142","Zoodyss\u00e9e","parc zoologique","Villiers en Bois"],["139","Zoo de l'Orangerie","parc zoologique","Strasbourg"],["141","Zoo de Jurques","parc zoologique","Jurques"],["125","Zoo d'Attilly","parc zoologique","Ozoir-la-Ferriere"]],"ids":[],"new":[["127"],["142"],["139"],["141"],["125"]]});
This discussion has been closed.
Replies
Either there are only 5 records matching your db-query without LIMIT or your serverside code is 'wrong'/has a flaw in logic.
iTotalRecords should be the number of matching db-entries without 'LIMIT' (http://www.datatables.net/usage/server-side)
aaData should contain up to iDisplayLength entries.
pagination with next/back button should display if iDisplayLength
Now I understand, thanks