I came across this prolem when using datatables to display records via an ajax call.
However many results I choose per page the pagination only shows one page even when not all records are displayed.
So, with 12 possible records and 5 records per page, the table displays
"Displaying 5 of 5 records (filtered from a possible 12)".
but there is only 1 page, not 3 in the pagination section.
iDisplayLength is 5
in the json response
iTotalRecords 12
iTotalDisplayRecords 5
Why is it not showing the 3 pages it should?
The problem was my misunderstanding of how to apply the paging server side and what value to return for iTotalDisplayRecords.
iTotalDisplayRecords is NOT the number of records being displayed on the page, it is the number of records that would be displayed, after filtering, if there was no pagination.
I was calculating iTotalDisplayRecords as the number of records being returned for each page (in this case 5) what resolved the problem was calculating this number BEFORE applying limit and offset but after any other filters (in my case date range and result type)
Hope this helps someone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With