Server-side and polling with fnDraw -- remembering page?
Server-side and polling with fnDraw -- remembering page?
There are actually many threads on this, so I suspect the answer is out there... out there... out there... but since some of the threads are from 2009 I'm finding it hard to figure out which are still relevant, so I'll do the cowardly thing and ask anew:
Using server-side processing and we are continually updating our tables using setInterval with an fnDraw() of the table object. We are also using pagination. Finally, bStateSave is true, though I'm not 100% sure that's related.
Visualize: On initial load, the table is drawn, providing a set of data based on iDisplayStart being 0.
Click "page 2".
The application does indeed go to page 2, and iDisplayStart is correctly 25 (each page has 25 rows). All is good in the world!
Wait until the polling interval passes, at which time fnDraw is fired again. Uh-oh, dumped back to page 1. Sure enough, iDisplayStart was 0 for the request. All I can imagine is that at the time of initialization, 0 was the correct starting point. Is it that each fnDraw is trying to recreate the initialization scenario? (side note: Does that mean that filters will also be discarded when the polling interval circles around? Something to consider as we move forward)...
How do I stay on page 2? I understand that filtering or sorting should dump you to page 1 again, but assuming no filtering or sorting, we'd like to stay on page 2. Is there a variable I've missed?
Using server-side processing and we are continually updating our tables using setInterval with an fnDraw() of the table object. We are also using pagination. Finally, bStateSave is true, though I'm not 100% sure that's related.
Visualize: On initial load, the table is drawn, providing a set of data based on iDisplayStart being 0.
Click "page 2".
The application does indeed go to page 2, and iDisplayStart is correctly 25 (each page has 25 rows). All is good in the world!
Wait until the polling interval passes, at which time fnDraw is fired again. Uh-oh, dumped back to page 1. Sure enough, iDisplayStart was 0 for the request. All I can imagine is that at the time of initialization, 0 was the correct starting point. Is it that each fnDraw is trying to recreate the initialization scenario? (side note: Does that mean that filters will also be discarded when the polling interval circles around? Something to consider as we move forward)...
How do I stay on page 2? I understand that filtering or sorting should dump you to page 1 again, but assuming no filtering or sorting, we'd like to stay on page 2. Is there a variable I've missed?
This discussion has been closed.
Replies
http://www.datatables.net/ref#fnSort
[quote]
bool (optional): indicate if the redraw should be complete (i.e. re-sort and re-filter), which has the side effect of resetting the pagination, or just update the display as it is. Default - true[/quote]
there's a plug-in function to perform a "standing redraw" which re-sorts and stuff, but memorizes your position.
http://www.datatables.net/plug-ins/api#fnStandingRedraw