Select all rows while using pagination
Asked Answered
C

1

1

I have a table and SELECT ALL checkbox. I am using Bootstrap DataTable to paginate through table and I would like SELECT ALL to select all rows across the pages. Is that possible and how?

I use this, but it works only when I return to that page, not when I first click on it.

$("#table").on( 'page.dt',   function () {
  if($('#select-all').is(":checked")){
    $(".bulk-checkbox").prop("checked", "true");
  }
  else {
    $(".bulk-checkbox").removeAttr('checked');
  }
 });

Thanks

Cockle answered 14/9, 2015 at 9:42 Comment(0)
C
1

Ok, it worked like this:

$("#table_paginate").click(function () {
  if($('#select-all').is(":checked")){
    $(".bulk-checkbox").prop("checked", "true");
  }
  else {
    $(".bulk-checkbox").removeAttr('checked');
  }
});
Cockle answered 14/9, 2015 at 11:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.