Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select all rows in active page only jquery Datatable

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?

like image 824
Sandeep Thomas Avatar asked Nov 20 '14 12:11

Sandeep Thomas


People also ask

How to select all rows in datatable jQuery?

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.

How do I select all checkboxes from all pages in jquery Datatable grid?

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(!


2 Answers

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..

like image 117
Sandeep Thomas Avatar answered Oct 21 '22 10:10

Sandeep Thomas


Use dataTables.checkboxes.min.js , Use option "selectAllPages" : false . It should be work and it's easy

like image 34
kishore cheruku Avatar answered Oct 21 '22 10:10

kishore cheruku