Dynamic enabling / disabling of scroller

Dynamic enabling / disabling of scroller

sronsieksronsiek Posts: 52Questions: 11Answers: 0

Hi,

Version Info: DT 1.11.4 scroller 2.0.5

I'm rendering a sorted table (~10k) rows with paging, deferred render and scroller enabled. serverSide is false so the entire table data is sent by the server via ajax, but scroller manages selective rendering of viewable data.

Scroller looks to be very good at what is does, though there is obviously an overhead and some visible signs of it's operation.
So I would like to have the best of both worlds - something like: when the table data from the ajax request is received in the dataSrc callback, check the number of rows and dynamically enable / disable scroller. That way I get the smooth operation for smaller datasets, but the benefit of scroller with larger ones.

Does this sound feasible?

If scroller cannot be disabled dynamically, is there perhaps the possibility to control the number of records it batch-renders
ie set this to all when the number of records is less than, say 1000 ?

Looking forward to your suggestions,
Stef

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599
    Answer ✓

    You can't enable/disable Scroller programmatically, but you could get the data first with your ajax call. Then check how many records there are before initialising the table, and enable Scroller then if needed - something like this: http://live.datatables.net/turutexu/1/edit

    Colin

  • sronsieksronsiek Posts: 52Questions: 11Answers: 0

    Excellent, thank you - this is now working. Only downside was that the user was staring at a mostly blank page while the ajax call is transferring data, so I now display a temp empty table with the 'Processing' div unhidden. In the success callback I then destroy this before creating a new table with the data.

Sign In or Register to comment.