title: Select all checkboxes does not work on next page in JQuery datatables
body: <p>I am using JQuery datatables. I want to add select all column with checkboxes so that when I click on 'select all' check box all the checkboxes on that page should get selected.</p>
  
  <p>I am using the following code:</p>
  
  <pre><code>&lt;table id="myTable" cellspacing="0" width="100%"&gt;
      &lt;thead&gt;
          &lt;tr&gt;
              &lt;th&gt; Name&lt;/th&gt;
              &lt;th&gt; Type&lt;/th&gt;
              &lt;th&gt; Details&lt;/th&gt;
              &lt;th&gt;Select &lt;input type="checkbox" name="select_all" value="1" id="select-all"&gt;&lt;/th&gt;
          &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
          &lt;?php foreach ($test as $data) { ?&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;?php echo $data-&gt;name; ?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;?php echo $data-&gt;type; ?&gt;&lt;/td&gt;
              &lt;td&gt;&lt;a href="/details"&gt;view details&lt;/a&gt;&lt;/td&gt;
              &lt;td&gt;&lt;input type="checkbox" name="manuf[]" class="sub_chk" data-id="&lt;?php echo $data-&gt;id; ?&gt;"&gt;&lt;/td&gt;
  
  
          &lt;/tr&gt;
          &lt;?php } ?&gt;
      &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;script&gt;
  $(document).ready(function(){
  $('#myTable').DataTable();
  });
  
  $('#select-all').on('click', function(e) {
  if($(this).is(':checked',true))  
  {
      $(".sub_chk").prop('checked', true);  
  }  
  else  
  {  
      $(".sub_chk").prop('checked',false);  
  }  
  });
  &lt;/script&gt;
  </code></pre>
  
  <p>The above code works for the first page of the datatable but if I select the second page and if I select 'Select all' checkbox, it takes me to the first page instead of selecting the checkboxes in the second page.</p>
  
  <p>Is there a solution to this? </p>