columns([0, 1]).search filters everything
columns([0, 1]).search filters everything

I built check box filter to allow users to toggle see normal items (value of 0) and abnormal ( value greater than 0). These values span across several columns.
If all columns for a row have a value of 0 then it should be filtered out when the check box is checked. I can get it to work for 1 column but not multiple columns. Instead it filters all the rows out.
https://datatables.net/reference/api/columns().search() shows that this should work -
table.columns( [0, 1] ).search( 'Fred' ).draw();
In my code, I have done similar but cannot get it function right. It filters everything out.
//This works
table.column(2).search(_checked, true, false, false).draw(false);
//This works
table.columns([1]).search(_checked, true, false, false).draw(false);
//This does not work -
table.columns([1,2]).search(_checked, true, false, false).draw(false);
This question has an accepted answers - jump to answer
Answers
Hi @glimpsed_chaos ,
It's not working because
will only return rows where all four columns contain a '1'. It's the same as saying:
To do an OR search across the columns, you need a custom search plugin. Kevin did a good one here from this thread.
Cheers,
Colin
Got it! Thank you for your time.
This works now. I had to swap some of the logic from Kevin's example. But now I get all 3 rows as expected when I click the checkbox if any column (1 - 4) has a value greater than 0 in a cell.
http://live.datatables.net/cesayede/4/
Excellent, glad all working.