How would one keep old rows when using Scroller and bServerSide?

How would one keep old rows when using Scroller and bServerSide?

twitchaxtwitchax Posts: 7Questions: 0Answers: 0
edited February 2014 in Plug-ins
Hello, my question is pretty simple. Right now, if one uses the Scroller and [code]"bServerSide": true[/code], then new data will be loaded as you scroll. However, upon scrolling down for new data, the old table rows are thrown away.

Is there a way to allow Scroller to keep the old rows? That way, upon scrolling back up, one will not need to hit the server again to get the data (whose filtering and sorting have not changed) that was just received seconds ago.

Is it possible to use the Scroller to defer the loading of the data (so the UI looks responsive) but keep the rows once created (assuming the filter and sort hasn't changed)? Am I missing something here (using DataTables 1.9.4 and Scroller 1.2.0)?

Replies

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    > the old table rows are thrown away.

    Correct - that's how server-side processing operates. It will only hold a reference to the rows that it needs for the current display. There is no way around that when server-side processing is enabled.

    The closest you would get is something like the pipelining demo: http://datatables.net/release-datatables/examples/server_side/pipeline.html

    Allan
  • twitchaxtwitchax Posts: 7Questions: 0Answers: 0
    Yeah, last night, I went digging through the code and saw the "nuke the old rows" comment...and I was like, "well, there you have it." Haha.

    I see that the pipelining could work. Basically, say your first call is (0,50), when the user scrolls down, you can just fake the next call to be (0,100)? That seems like it should work.

    However, I am dealing with a maximum of 2000 rows here, so (I saw a thread where this was not possible in 1.6.X) is there a way to override the private methods (like _fnSort/_fnFilter)?

    Thanks!
  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    With only 2000 rows, I wouldn't bother with Scroller. Unless you need old IE to run it as well. Current IE, Chrome, Firefox etc are all plenty fast enough for only 2000 rows.

    Allan
  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    p.s. No - the private methods can't be modified as they are internal. You would need to edit the source file (it is open source :-) ).

    Allan
  • twitchaxtwitchax Posts: 7Questions: 0Answers: 0
    To clarify...I was already doing something similar to the pipelining...I am really interested in reducing the amount of TRs that are rendered. I already have the data, but when I do a sort on 1000 rows (I pipelined them, so I don't even make a server call, I sort locally), the largest portion of the time is the recreation of the TRs (which takes 2-4 seconds).
  • twitchaxtwitchax Posts: 7Questions: 0Answers: 0
    Yeah, you make a good point...but a sort that "calls" to the server would then redraw the rows, which is where I am getting my performance hit.

    Really, I can get all the data at once...I just want to do the sort and filter completely manually.

    So, in the end...I don't care whether I have bServerSide true or false, I just want to completely own the sort and filter logic (which is why I used bServerSide true, because it seems like the fastest way to put the logic in my own hands)...but I would also like to not have to wait for the 2-4 second draw.

    So, is there a good example of bServerSide false where I can do all of the sort and filter logic myself? :)
  • twitchaxtwitchax Posts: 7Questions: 0Answers: 0
    And thanks for the great info, by the way.
  • twitchaxtwitchax Posts: 7Questions: 0Answers: 0
    I guess one option might be to update to 1.10 and utilize orthogonal data: http://next.datatables.net/manual/orthogonal-data ?
  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    That's one option. For basic sort control use a plug-in sorting method: http://datatables.net/development/sorting#type_based . That's a simple Javascript compare function which is good enough for 99% of sort cases.

    For the other 1% you can use completely custom sorting. A bt more tricky, but you can sort the table in any way you want: http://datatables.net/development/sorting#data_source

    Filtering has similar options: http://datatables.net/development/filtering

    However, if the built in methods are good enough with orthogonal data, then I'd say that is a good way to go.

    Allan
  • twitchaxtwitchax Posts: 7Questions: 0Answers: 0
    Great...thanks for all the help. I will take a stab at the orthogonal data implementation first. Thanks!
This discussion has been closed.