Changing to not-yet-existent page number with server-side processing
Changing to not-yet-existent page number with server-side processing
I'm using server-side processing and saving state manually including my own list and status combination and the datatables page number. Whenever state pops I set the page number and draw the table. This works fine except when I change from a state with fewer pages than the next state. Say I start on page 2, then change status to one with zero rows, then go back. It always displays the info (e.g. "1 to 10") and page highlight for page 1, not 2 (e.g."11 to 20"). It seems datatables won't let me set the page with table.page to a non-existent value before the draw and defaults to zero internally (this was confirmed by setting and then reading table.page). This causes the ajax to request a start of 0. However, even if I overwrite data.start using the ajax.data function and successfully request the correct start row and get back the data for that row from the server datatables insists on displaying the info and page highlight for the first page. Is there any way for me to update the internal page pointer to the correct page, without doing a second request?
Answers
I believe I have mitigated the issue with the following code to set internal data to my saved start value instead of using a saved page value, with no ajax.data modification needed:
Hi @dw1 ,
Another option would be to consider using
stateSave
- this is similar to what you did manually, i.e. return to the previous settings (page number, ordering, etc), but all done internally.Cheers,
Colin