Modify datatable settings on ajax post back with server side processing

Modify datatable settings on ajax post back with server side processing

yhaxyhax Posts: 3Questions: 1Answers: 0
edited July 2015 in Free community support

I am using datatables with server side processing. I am having an issue with the page numbering. These are my settings:

settings['bLengthChange'] = false;
settings['pageLength'] = recordsPerPage; // 11 in this case
settings['serverSide'] = true;
settings['ajax'] = {"url": location.pathname,"type": "POST" };

The first time the page loads, the ajax makes the call and the following is returned:

Showing 1 to 11 of 503 entries

Which looks good and is what I want. However, when I switch to a different page, let's say page 2, I get the following:

Showing 11 to 503 of 503 entries

so the ajax response for both is identical (the data is different and the draw id changes, which is expected). I tried hooking the ajax event and modifying some settings (pageLength, iDisplayTotal,iDisplayRecords etc etc) and while it changed the settings, nothing changed visually. I also tried deleting the table and adding the data again with an fnDraw but you can't do that with server side processing.

Any ideas?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 64,032Questions: 1Answers: 10,555 Site admin
    Answer ✓

    Per the forum rules, can you please link to a test case showing the issue so we can debug it.

    Allan

  • yhaxyhax Posts: 3Questions: 1Answers: 0

    Hi Allan,

    Thanks for getting back to me. I am unable to expose the api I am using for any samples hence I can't set one up with the ajax call. I can try setup a new, exposed api somewhere but that may take some time. In the mean time if you need to see specific files / data in a certain state, please let me know.

  • yhaxyhax Posts: 3Questions: 1Answers: 0

    Found the issue, it seems to be a timing problem with some other scripts that is causing it. Thanks.

This discussion has been closed.