How to get all the rows selected on different pages from a paginated dataTable ?
How to get all the rows selected on different pages from a paginated dataTable ?
I am using pagination in my datatable.
The following code adds checkboxes to 8th column of each data row of the table:
columnDefs: [ { orderable: false, className: 'select-checkbox', targets: 7} ]
And this code makes the checkbox clickable and the row selectable:
select: {'style': 'multi'}
The user can select rows from different pages by clicking on the checkbox or anywhere on the row area.
How can I get all the rows selected on different pages ?
The following jquery code only gets me the rows selected on current page:
$("tr.selected")
Quick response would be helpful. Thanks
This question has an accepted answers - jump to answer
Answers
When you say you are using "pagination" to you mean you have
severSide
enabled? If so then you will only get the selected rows of the current page.If you are using client side then this example should help:
https://datatables.net/extensions/select/examples/api/get.html
Kevin
Thanks, it worked! I am using client-side pagination.
The following code did what I needed:
table.api().rows( { selected: true } )
I had to add api() call. As far as I understand:
If we are using dataTable, then, to use available methods, we need to add api() call like:
table.api().rows()
Else, if we are using DataTable, then we need to do:
table.rows()