Issues with pagination with server side datasource
Issues with pagination with server side datasource
sciamannikoo
Posts: 3Questions: 0Answers: 0
Hello.
Using the examples provided, I've a table with a server side datasource.
Everything works fine: sorting, filtering and rows per page.
But paginations doesn't seem willing to work pagination controls are always disabled.
If I've set the plugin to use 'full_numbers' pagination type, I see only one page.
I can't provide a live example, but here is the jquery:
[code]
$adminTables.dataTable({
"bPaginate": true,
"sPaginationType": "full_numbers",
"aoColumns": [
{ "sClass": "center", "bSortable": false },
{ "sClass": "center", "bSortable": false },
null,
null,
null,
null,
null,
null,
null,
null,
null,
null
],
"bFilter": true,
"bInfo": false,
"bAutoWidth": true,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "<?php app_root_full_url('lib/admin/server_auctions.php', isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : false);?>"
});
[/code]
And here the returned json:
[code]
{"sEcho":5,"iTotalRecords":"3390","iTotalDisplayRecords":10,"aaData":[["...","+++","ASanFranciscoHome.com","-","850","-","-","CA","none","-","1","-"],["...","+++","LosAngeles2Go.com","-","850","-","-","CA","none","-","1","-"],["...","+++","LosAngeles4You.com","-","850","-","-","CA","none","-","1","-"],["...","+++","4LosAngelesHomes.com","-","750","-","-","CA","none","-","1","-"],["...","+++","4LosAngelesRealEstate.com","-","750","-","-","CA","none","-","1","-"],["...","+++","ALosAngelesHome.com","-","750","-","-","CA","none","-","1","-"],["...","+++","MovingSanDiegoHomes.com","-","750","-","-","CA","none","-","1","-"],["...","+++","SanJose4You.com","-","750","-","-","CA","none","-","1","-"],["...","+++","4SanAntonio.com","-","575","-","-","TX","none","-","1","-"],["...","+++","OwnLosAngelesHomes.com","-","575","-","-","CA","none","-","1","-"]]}
[/code]
With Chrome's developer tools, in the network tab, I see that a call is mate to the server-side script on load and each time a sorting or a filter is done.
Pagination controls have the disabled class, as I've already written and clicking on them, of course, doesn't do anything (i.e. no calls to the server_auctions.php script).
Any hint?
Using the examples provided, I've a table with a server side datasource.
Everything works fine: sorting, filtering and rows per page.
But paginations doesn't seem willing to work pagination controls are always disabled.
If I've set the plugin to use 'full_numbers' pagination type, I see only one page.
I can't provide a live example, but here is the jquery:
[code]
$adminTables.dataTable({
"bPaginate": true,
"sPaginationType": "full_numbers",
"aoColumns": [
{ "sClass": "center", "bSortable": false },
{ "sClass": "center", "bSortable": false },
null,
null,
null,
null,
null,
null,
null,
null,
null,
null
],
"bFilter": true,
"bInfo": false,
"bAutoWidth": true,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "<?php app_root_full_url('lib/admin/server_auctions.php', isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : false);?>"
});
[/code]
And here the returned json:
[code]
{"sEcho":5,"iTotalRecords":"3390","iTotalDisplayRecords":10,"aaData":[["...","+++","ASanFranciscoHome.com","-","850","-","-","CA","none","-","1","-"],["...","+++","LosAngeles2Go.com","-","850","-","-","CA","none","-","1","-"],["...","+++","LosAngeles4You.com","-","850","-","-","CA","none","-","1","-"],["...","+++","4LosAngelesHomes.com","-","750","-","-","CA","none","-","1","-"],["...","+++","4LosAngelesRealEstate.com","-","750","-","-","CA","none","-","1","-"],["...","+++","ALosAngelesHome.com","-","750","-","-","CA","none","-","1","-"],["...","+++","MovingSanDiegoHomes.com","-","750","-","-","CA","none","-","1","-"],["...","+++","SanJose4You.com","-","750","-","-","CA","none","-","1","-"],["...","+++","4SanAntonio.com","-","575","-","-","TX","none","-","1","-"],["...","+++","OwnLosAngelesHomes.com","-","575","-","-","CA","none","-","1","-"]]}
[/code]
With Chrome's developer tools, in the network tab, I see that a call is mate to the server-side script on load and each time a sorting or a filter is done.
Pagination controls have the disabled class, as I've already written and clicking on them, of course, doesn't do anything (i.e. no calls to the server_auctions.php script).
Any hint?
This discussion has been closed.
Replies
That's wrong.
From the documentation ( http://datatables.net/usage/server-side ):
> iTotalDisplayRecords - Total records, after filtering (i.e. the total number of records after filtering has been applied - not just the number of records being returned in this result set)
Allan
However, now I don't get the difference between iTotalRecords and iTotalDisplayRecords, as once I set both options to the same value, everything works fine.
> iTotalRecords - Total records, before filtering (i.e. the total number of records in the database)
> iTotalDisplayRecords - Total records, after filtering (i.e. the total number of records after filtering has been applied - not just the number of records being returned in this result set)
It's the "before" and "after" filtering that is the important part.
Allan
You gave for granted that I've misunderstood the meaning of this option and with your answer you've just added confusion.
Instead, I was using this option properly, but there was a mistake in the server side code, where I've forgotten to use "SQL_CALC_FOUND_ROWS" in the called query, getting a wrong value when querying FOUND_ROWS().
Anyway, problem solved.
Thank you.