Checkbox checked on filtered rows

Checkbox checked on filtered rows

perelliperelli Posts: 3Questions: 1Answers: 0
edited February 2015 in Free community support

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.

Answers

This discussion has been closed.