Adding callback / holding current pagination to $.fn.dataTable.pipeline script
Adding callback / holding current pagination to $.fn.dataTable.pipeline script
tdmohr
Posts: 16Questions: 2Answers: 0
I'm using the $.fn.dataTable.pipeline script (https://datatables.net/examples/server_side/pipeline.html) and am really missing the ability to add a callback and hold the pagination position on table reload. Ideally we could add similar functionality to the script as we can when using the plain ajax reload method (https://datatables.net/reference/api/ajax.reload()).
Is there any possibility we could shoehorn this functionality into the dataTable pipeline workflow?
Tim
Answers
Both the callback and staying on the same page seem to work here with the pipelining script:
https://live.datatables.net/dijuqeti/1/edit
Maybe I'm misunderstanding the question. Can you update the test case to show the issue you are trying to solve?
Kevin
Hi Kevin,
Thank you very much for your reply and thanks for making the test case.
I've been using the
clearPipeline
function, which appears to be required to draw changes made to the data into the table.I just tested with
ajax.reload
and it does appear that whilst the callback fires, and pagination is maintained, the table is not redrawn with the changed data.I'm not sure if its possible to modify the test script to show this as the data needs to be changed.
I've been working on modifying the pipeline script to allow this, and will happily share it once I'm confident its actually working correctly.
Thanks,
Tim
Unfortunately not.
Do the changes show if you reload the page? Use the browser's network inspector to verify the XHR request and what is in the response.
That is using
draw()
which will fetch the data from the server. Shouldn't be any different thatajax.reload()
. However in the place ofajax.reload()
you could use thedraw()
API passing in eitherpage
or false, depending on your needs, to refresh the data from the server and stay on the same page.Kevin
Yes. The table is updated after page reload.
To clarify, when I pass false into the draw function, pagination is maintained, but no changes are shown until page reload.
Ok. Did you check the XHR response? If the changes are in the response then we will need a test case showing the issue to help debug. If the changes aren't in the response then the server script will need debugging.
Kevin
Hi Kevin,
I can do one better... below is the pipeline script modified to allow AJAX callback and redraws the data without affecting pagination:
Table reload is triggered like:
Hope this helps someone in the future.
Kind regards,
Tim
@tdmohr Nice, thanks for posting,
Colin