Pagination from Page 2 on not working

Pagination from Page 2 on not working

thebigmemphthebigmemph Posts: 2Questions: 2Answers: 0


i'm filling my datatable with a server side processing php script.
The datatable initialize just fine, but if im changing to page 2 the data received from the server changes.

This is the data i receive on page 1:

{"draw":1,"iTotalRecords":"87","iTotalDisplayRecords":"87","aaData":[{"Feld":"id","Data":"1"},{"Feld":"Abrechnungsart","Data":"Selbstzahler"},{"Feld":"Anrede","Data":"Frau"},{"Feld":"Vorname","Data":"kkkkk"},{"Feld":"Name","Data":"bbbbbbb"},{"Feld":"Strasse","Data":"tttttttt"},{"Feld":"Stadt","Data":"11111 City"},{"Feld":"abweichende_Rechnungadresse","Data":"0"},{"Feld":"Rechnung_Empfaenger","Data":""},{"Feld":"Rechnung_Strasse","Data":""}]}

And this is the data i receive on page 2 and any further pages:


The data is built the same way, either it is page 1 or page 2:

$data[$columnCount]["Feld"] = $rowField;
$data[$columnCount]["Data"] = $value;
$response = [
   'draw' => intval($draw),
   'iTotalRecords' => $totalRecords,
   'iTotalDisplayRecords' => $totalRecordwithFilter,
    'aaData' => $data,

I don't understand why the data on page 2 and further has this leading numbers before the data.

This question has an accepted answers - jump to answer


  • allanallan Posts: 54,900Questions: 1Answers: 8,605 Site admin
    Answer ✓


    This is incorrect. aaData (or data if you prefer the newer notation) should be a 0 indexed array. It is in your first block, but it appears to be using the row position in the display after that, rather than just counting from 0 again.

    What is what is causing DataTables to not display the second page of data. How to fix it? That will depend upon your server-side script. It sounds like $data needs to be created a little differently from how you are doing it just now.


Sign In or Register to comment.