Scroller, server-side processing and select/click rows

Scroller, server-side processing and select/click rows

randgaltrandgalt Posts: 7Questions: 0Answers: 0
edited February 2012 in General
None of the examples for row selection work when using the Scroller and server-side processing. How do I enable row selection with these options?

Replies

  • allanallan Posts: 63,542Questions: 1Answers: 10,476 Site admin
    This is a little bit of a non-trivial problem - not insurmountable of course, but there are details that need to be considered. The main thing to note is that when you have server-side processing enabled, rows only exist for the life time of a single draw (since the data is at the server, not the client) - and a single draw when using Scroller is just the visible part of the table ( http://datatables.net/blog/Introducing_Scroller_-_Virtual_Scrolling_for_DataTables ).

    So what is happening is that when you move Scroller to a different part of the table, the nodes that you had before are destroyed and the new required ones created. This since most of my demos just use classes on the nodes to indicate what rows are selected, this information is lost.

    So what must be found is another way to store this information and to apply it on each draw. Typically the method I use is to keep a Javascript array with the IDs of all the rows in the table that are selected (use the DT_RowId option), and remove them from this array when needed. Thus when the table is redrawn, the rows can be marked as visually selected again.

    I have an example that shows how this can be done here: http://datatables.net/release-datatables/examples/server_side/select_rows.html . This method will work with Scroller as well, since Scroller just just uses the pagination feature of DataTables :-)

    Regards,
    Allan
This discussion has been closed.