[RESOLVED] Datatables server-side problem to pagination (number of page not correct)
[RESOLVED] Datatables server-side problem to pagination (number of page not correct)
Hi,
I have a problem with the datatables server-side ( DataTables 1.10.4 , jQuery v1.11.1 and Bootstrap v3.3.1 ).
I have inizialized the DataTable in this mode:
$('#datatables-4').dataTable( {
"processing": true,
"serverSide": true,
"order": [[ 3, "desc" ]],
"ajax": baseUrl+"shoes/ProcessingDatatables"
}
Records Totale is 216,,
The ajax response is:
draw: 1
recordsTotal: 216
recordsFiltered :10
data: array data etc etc.
The problem is that the number of pages is 1, but should be 22 pages ( 216 Records / 10 = 22 Pages).
This is the screenshots of the paging https://www.dropbox.com/s/9sx5iof4v0soau3/DataTables.png?dl=0
can you help?
ersecchio
This discussion has been closed.
Replies
The screenshot says
so it is correct that pagination only has one page. You need to find out where you are applying a filter or query while retrieving the data.
It should be 216 in this case unless you have a filter applied as @tangerine says.
Allan
At load of page the datatables sent via GET to the various parameters, the following
....
length = 10
order[0][column] 3
order[0][dir] desc
search[regex] false
search[value]
start = 0
...
then "start" and "length".
The controller of server inizialize the response variabile in this mode:
"recordsTotal" = > Select all records from table, without filtering = SELECT * FROM table
"recordsFiltered" => Select records from table with LIMIT, then "start" and "lenght" = SELECT * FROM table LIMIT 0, 10.
"data" => array of 10 items
and then
recordsTotal: 216
recordsFiltered :10
maybe something wrong?
Yes -
recordsFilteredis not the page length. It would be worth reading over the documentation for those parameters:Allan
RESOLVED.
The "recordsFiltered" has a value different of "recordsTotal". The "recordsFiltred" is the number of items after globalSearch or columnSearch.
If there is no search (globalSearch or columnSearch) , then the value "recordsFiltered" is equal to "recordsTotal".
:)