Select all filtered rows doesn't work
Select all filtered rows doesn't work
fansisk
Posts: 4Questions: 0Answers: 0
Hi all. I tried writing a function that will be executed by a 'Select All' checkbox, and it will select all checkboxes of the current filtered rows. Every row has a checkbox among other columns.
This code works but it checks all the checkboxed of all rows, not only the filtered ones.
var myTable = $('#test_table').dataTable();
$('input', myTable.fnGetNodes()).attr('checked', obj.checked);
but if i write
var myTable = $('#test_table').dataTable();
var filteredRows= myTable._('tr', {"filter": "applied"});
$('input', filteredRows).attr('checked', obj.checked);
it doesn't do anything. Can anyone tell me why it doesn't work, or point me to a better solution to achieve my goal?
This code works but it checks all the checkboxed of all rows, not only the filtered ones.
var myTable = $('#test_table').dataTable();
$('input', myTable.fnGetNodes()).attr('checked', obj.checked);
but if i write
var myTable = $('#test_table').dataTable();
var filteredRows= myTable._('tr', {"filter": "applied"});
$('input', filteredRows).attr('checked', obj.checked);
it doesn't do anything. Can anyone tell me why it doesn't work, or point me to a better solution to achieve my goal?
This discussion has been closed.
Replies
[code]
$('#test_table').dataTable().$('tr input', {filter:'applied'}).prop( 'checked', obj.checked);
[/code]
Allan
[code]
$('#test_table').dataTable().$('input', {filter:'applied'}).prop( 'checked', obj.checked);
[/code]
If not that then console.log some of the results and see what is what.
Allan
I think it would be very good, if you write this code somewhere that everyone can see it, because as i was looking for that solution, i saw a lot of posts relating to that, unanswered...
But, great work. Thanks again
Allan