0

We are using data tables with pagination and we need a select all checkbox in the header row, which would select only the rows in the current page.

When you have selected first page, if you go to next page, the select all checkbox should be unchecked and if you check, it should select second page rows. And if you go back to page 1, it should still show selected rows and the select all checkbox checked.

I could not find a solution for this, as everyone had asked how to select every row in all pages, this is kind of distinct scenario.

madth3
  • 7,275
  • 12
  • 50
  • 74

2 Answers2

0

Assuming that the page isn't completely being refreshed, you could do this a couple of ways.

You could create a hidden table for each page, as it's rendered, and then check to see if the table for has already been created. If it has, just display the existing table. The state of the table will still be in place. The elegance of this is that you don't have to keep going back to the server, but it wouldn't necessarily scale if you had a lot of pages.

You could also create an array of checked IDs and then when rendering a specific page, check to see if the checkboxes are in that array.

Brian Hoover
  • 7,861
  • 2
  • 28
  • 41
0

If you are using pagination you should know how many items show in every page...

carlituxman
  • 1,201
  • 12
  • 22