I'm using jquery datatable on a gidview and there is a checkbox on the datatable header. The purpose of that checkbox is to check all checkboxes in the current page of the gridview rows.
So am using the function
var table = $('#Tab_ApplicantList').DataTable();
var rows = $('#Tab_ApplicantList').dataTable().fnGetNodes();
$(rows).each(function () {
$(this).find("input.grey").iCheck('check');
});
But the problem is it is selecting all rows in the datatable, not just the rows in the active page. So how can I achieve that to check rows in the current page alone?
The selectAll button will simply select all items in the table, based on the current item selection mode ( select. items() ) - e.g. if the item selection mode is rows , all rows in the table will be selected when this button is activated.
nodes(); // Check/uncheck checkboxes for all rows in the table $('input[type="checkbox"]', rows). prop('checked', this. checked); }); // Handle click on checkbox to set state of "Select all" control $('#example tbody'). on('change', 'input[type="checkbox"]', function(){ // If checkbox is not checked if(!
I've got an answer to my question and sharing for those with similar issue..
var table = $('#tbl_questions').DataTable();
var p = table.rows({ page: 'current' }).nodes();
will return all the rows in the current page only..
Use dataTables.checkboxes.min.js , Use option "selectAllPages" : false
. It should be work and it's easy
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With