Datatable passing wrong draw with server side pagination

Datatable passing wrong draw with server side pagination

princewillprincewill Posts: 3Questions: 1Answers: 0

Hello,

I am having issues with server side pagination. My issue is particulalry with the draw value.

Let's say we have a total of 100 records to be displayed 10 records per page. I noticed that when data is loaded and we go from page 1 to 2 to 3 then 4 and back to 3 the draw value becomes 5 because technically, i have drawn 5 times from the records list.

The impact is that the reloaded page 3 now has records for page 5. Please how do i achieve the desired cosisitent page.

Please find below my initialised datatable.


$('#authPendingList').DataTable({ "processing": true, "serverSide": true, "ordering": false, "filter": false, "bFilter": false, "ajax": { "url": "DataTableServlet", "type": "POST", "datatype": "json", "data": {approvalStatus: "N"} }, "aoColumns": [ { "mRender": function (data, type, row) { console.log("column 0: "); console.log(row); console.log(type); return row.data === undefined ? "" :row.data; } }, { "mRender": function (data, type, row) { console.log("column 1: "); console.log(row); console.log(type); return row.data === undefined ? "" : row.data; } }, { "mRender": function (data, type, row) { console.log("column 2: "); console.log(row); console.log(type); returnrow.data === undefined ? "" : row.data; } }, { "mRender": function (data, type, row) { console.log("column 3: "); console.log(row); console.log(type); return row.data === undefined ? "" : row.data; } }, { "mRender": function (data, type, row) { console.log("column 4: "); console.log(row); console.log(type); return row.data === undefined ? "" : row.data; } }, { "mRender": function (data, type, row) { console.log("column 5: "); console.log(row); console.log(type); return row.data === undefined ? "" :row.data; } }, { "mRender": function (data, type, row) { console.log("column 6: "); console.log(row); console.log(type); return row.data === undefined ? "" : row.data; } }, { "mRender": function (data, type, row) { console.log("column 7: "); console.log(row); console.log(type); return row.data; } } ] });

Answers

  • kthorngrenkthorngren Posts: 20,148Questions: 26Answers: 4,736

    The Server Side Processing docs describe the draw parameter. Its basically a sequence number that Datatables uses to make sure its drawing the correct data. Your response should return the draw sequence number in the response.

    If the data for the page is incorrect then you will need to troubleshoot the server script as that is what controls the data being shown on the page. You can use the browser's network inspector to monitor the XHR request and response to see what Datatables is receiving.

    Are you using a Datatables provided server side processing script?

    Kevin

  • princewillprincewill Posts: 3Questions: 1Answers: 0

    @kthorngren , I do return the draw value. The issue here is that the draw is contiously incremented. if for example i go from page 1 -> 2->3->4->5->4, i expect the current draw value to be 4, however i receive the draw value as 6.

    How do i resolve this issue

  • princewillprincewill Posts: 3Questions: 1Answers: 0

    @kthorngren Thank you for your reply, after reading through the doc, i realised i could achieve desired state with start and length . Thank you

This discussion has been closed.