Getting all selected rows

Getting all selected rows

c-myers1c-myers1 Posts: 43Questions: 16Answers: 0

Example here returns only items selected on the current page. How do I grab all items selected across all pages?

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,468Questions: 26Answers: 4,977

    The example works for me. You need to hold down control or shift to select multiple items.

    As a side note you can change the method for multiple selection:
    https://datatables.net/reference/option/select.style

    Kevin

  • c-myers1c-myers1 Posts: 43Questions: 16Answers: 0

    I don't think you understand. I'm using the stateSave true option. And so my table has 50 records, 25 per page : 2 pages. If I select 2 records on page 1 and hit the button, it alerts 2. I go to page 2 and select 3 more records then hit the button. Rather than alerting 5 it alerts only 3. if I page back to page 1, again it alerts 2.

    Hope this clarifies my need.

  • kthorngrenkthorngren Posts: 21,468Questions: 26Answers: 4,977

    Using -option stateSave` doesn't seem to affect getting the row count when going between pages in this example:
    http://live.datatables.net/bocogeho/1/edit

    Maybe you can update my example with your code so we can see the problem.

    Kevin

  • c-myers1c-myers1 Posts: 43Questions: 16Answers: 0

    Well, your jsbin is working exactly as I want.

    Replicating my scenario is a bit tricky as it involves serverSide/ ajax, createdRow, rowCallback entries, kendoUIDatePicker in each line each with onChange events, select and deselect events on the rows and a manual call to row.select() somewhere.

    Will look more closely at the code first but if you could give some pointers as to what to examine closer to solving this would be useful.

  • kthorngrenkthorngren Posts: 21,468Questions: 26Answers: 4,977
    edited April 2018 Answer ✓

    my scenario is a bit tricky as it involves serverSide

    I was thinking that this might be your issue but you mentioned going back to the first page and the two rows are selected. Are you writing these to the DB?

    Anyway with serverSide enabled the table.rows( { selected: true } ) is only going to look at what is in the client. In your case that is the page being displayed. If you are saving the checkbox state to a DB then you can query the DB for the items with the checkbox selected. Otherwise maybe you can use an array that contains selected row ID's and removes the rows that are deselected.

    Kevin

  • c-myers1c-myers1 Posts: 43Questions: 16Answers: 0

    That must be it then! Why the heck didn't anyone say so (in the documentation that is) and save me 2 days of head scratching!?!

  • kthorngrenkthorngren Posts: 21,468Questions: 26Answers: 4,977
    edited April 2018

    It is somewhat implied by the Server Side docs:

    server-side processing feature provides a method to let all the "heavy lifting" be done by a database engine on the server-side

    When using server-side processing, DataTables will make an Ajax request to the server for each draw of the information on the page (i.e. when paging, ordering, searching, etc.).

    Also its noted in the FAQ regarding Buttons and SSP. However you wouldn't run across this using Select.

    In most cases it is left to the developer to understand if the process or function used is a client side process. Anything dealing with table data is a client side process except the built-in searching, sorting and paging functions when SSP is enabled.

    Kevin

This discussion has been closed.