He Hui He Hui - 3 months ago 16
jQuery Question

Datatables pagination not responding as expected

I know there are lots of simliar questions out there, but I believe my scenario is different.

Using debug.datatables.net (the bookmark)

I noted the following response from my server.

"sEcho": 1,
"iTotalRecords": 234,
"iTotalDisplayRecords": 10,
"aaData": [
...10 data ...

However, I only get 1 page of results, resulting in no ajax calls whenever I click any pagination button.

Here's my script

"bProcessing": true,
"bServerSide": true,
"sAjaxSource": "{{ path('admin_booking_datatable') }}",
"aaSorting": [[ 0, "desc" ]],
"sPaginationType": "full_numbers",
"bPaginate": true

According to the documents, pagination is generated by taking

(iTotalDisplayRecords - iTotalRecords)/resultsPerPage

which, in reference to the data I've given back, should generate the correct paginations. Am I getting this wrong?




That's wrong.

To others who faced similar issues, note that iTotalDisplayRecords is not to be the number of results displayed per page. It's meant to be the total number of records after your database is filtered.