removing all rows with certain class on table with pagination
removing all rows with certain class on table with pagination
I have been unable to remove all rows based on a class assigned to each row.
Here is the addition of the class, which works to add a class of 'untracked-row' certain rows in the table.
"rowCallback": function( row, data, index )
{
if (!$('td button.tracked', row).length)
$(row).addClass('untracked-row');
}
I have a change event handler on a checkbox that will trigger this function. if the box is checked then all rows that are untracked should be removed:
function filtering(list)
{
return function ()
{
console.log($(this)[0].checked)
if ($(this)[0].checked)
{
$(list).DataTable()
.rows('.untracked-row')
.remove()
.draw();
}
else
{
loadDiscoverList();
}
};
This works, but only for the first page of the datatable, no subsequent pages remove the rows with the class .untracked-row
Is it because the other rows on the subsequent pages are not in the DOM yet?
This posting seems to suggest that it should not matter that there is pagination:
https://datatables.net/forums/discussion/16256/deleting-rows-that-are-not-on-page
Any suggestions?
Answers
Okay. So I ended up doing something similar, but I used the indexes of the rows instead and I kept the intended functionality. I would still be interested in knowing if you can access the rows by class. I also forgot to mention that I am using deferred rendering.