Server-side and polling with fnDraw -- remembering page?

Server-side and polling with fnDraw -- remembering page?

GregPGregP Posts: 500Questions: 10Answers: 0
edited August 2011 in General
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?

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    fnDraw(bool) takes a parameter whether or not to re-sort and filter, which resets to page 0

    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
  • GregPGregP Posts: 500Questions: 10Answers: 0
    Awesome, fbas, I'll look into both those options. I think you know the API better than Allan himself!
This discussion has been closed.