Select Extension loosing selection with server-side paging or scroller extension

Select Extension loosing selection with server-side paging or scroller extension

juvojuvo Posts: 1Questions: 1Answers: 0

I am trying to use the select extension with server-side paging or virtual scrolling (through the scroller extension). Server-side loading happens through a custom ajax function.

However, when either navigating to another page or when scroller loads additional rows, then previously selected rows loose their selection. This is select 1.2.0 and datatables 1.10.12. I have also properly defined the rowId to refer to a unique ID from the data.

Through my research, I found contradicting statements and examples:

  • Select Issue #21 - Seems to indicate that selection across pages is not possible
  • This page regarding scroller+select integration states that these should play well, but the example loads all data in one step - somewhat pointless
  • This example shows how to retain selection while paging, but this is without the select extension, i.e. doing manual book-keeping with an array.
  • This post describes the same problem with a response that it should work with the latest version(s)
  • This page shows that selection is even retained across data reload

What is the true status of this? To me it feels like a very important use case.

Answers

  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin

    Fundamentally Select does no support the retention of selected rows across pages. It does (if you have a row id) for the current page.

    The reason why it doesn't support row selection across pages is that it would need to store which rows are selected. That is leaky since this is a client-side operation, while the data is all at the server-side. Consider for example if you select ten rows and then delete them on the server-side - the client-side wouldn't know that.

    However, I recognise this is a pain point and it might be that this just has to be sucked up and a leaky implementation created.

    It is something that is on my todo list.

    Regards,
    Allan

This discussion has been closed.