how to select /unselet allcheckboxes in all pages on click of a button

how to select /unselet allcheckboxes in all pages on click of a button

sandepsandep Posts: 7Questions: 5Answers: 0
edited March 2015 in Free community support

i am using data tables (1.10.5 )
i have data table with checkall button in header and checkbox on every row
presently using this
$.('#checkall).click(function () {
$('input', oTable.fnGetNodes()).attr('checked',checked');
});
but it is selecting only present page checkboxes..how to select all checkboxes in other pages also.
any help would be appreciated.thanks in advance

Answers

  • AllanCochraneAllanCochrane Posts: 41Questions: 1Answers: 2

    You'll have to add a call to a function in the drawCallback:

    // Select all checkboxes
    function addHandlerToCheckbox() {
      $('.select-all').click(function(){
        var value = $(this).prop('checked');
        $('.select-all-dependent').each(function(){
          $(this).prop('checked', value);
        });
      });
    }
    ...
      var settings = {
        ...
        drawCallback: function() {
          addHandlerToCheckbox();
        }
      };
    ...
      table = $('#table').DataTable(settings);
    
  • sandepsandep Posts: 7Questions: 5Answers: 0
    edited March 2015

    allan it is working for only present page i am calling the handler function in draw callback.is that ok

  • AllanCochraneAllanCochrane Posts: 41Questions: 1Answers: 2

    Hard to tell what is going wrong, perhaps you could create a test case on jsFiddle (use http://jsfiddle.net/46yyaaq7/1/ as a starting point)

This discussion has been closed.