Quantcast
Channel: Free community support — DataTables forums
Viewing all articles
Browse latest Browse all 35272

Checkbox checked on filtered rows

$
0
0

Hi

I am using datatable 1.9.4 (can't upgrade to 2.0 for various reasons).

I am trying to set checked state on checkboxes in a filtered dataTable that (can) span multiple pages by clicking on a Select All button. This button is supposed to set the checked state on all filtered data only.

I can only get my code to set the checked state on the checkboxes on the first page (maybe visible rows?) but any checkboxes on subsequent pages remain unchecked.

I have added a fiddle here: http://jsfiddle.net/ohj8t5kL/2/
To test: enter spain in the filter box. Below variable (filteredRows) now contains 4 rows:

// contains 4 rows for Spain
var filteredRows = $(dtTable).dataTable()._('tr', { "filter": "applied" });

However, when I loop these 4 rows with the following code, only items on the first page of the dataTable is set.

// only 3 rows checked:
filteredRows.forEach(function (row) {
     $('#mytable input[value="' + row[0] + '"]').prop('checked', checked);
 });

Hoping for some advice

Best
Perelli.


Viewing all articles
Browse latest Browse all 35272

Trending Articles