I have an html table:
_A_B_C_D_
|0|1|0|1|
|0|1|0|0|
|1|0|0|1|
I want to filter non-zero columns. Using jQuery dataTables (not a hard requirement, just what I am currently using) I execute the following filter:
// value is the column index, true simply informs the filter method to use regex
dataTable.fnFilter("[^0]", value, true);
However, filtering multiple columns creates an AND filter. Thus:
dataTable.fnFilter("[^0]", 0 /*A*/, true);
dataTable.fnFilter("[^0]", 3 /*D*/, true);
would create the following
_A_B_C_D_
|1|0|0|1|
I need OR behavior though which would create the following table:
_A_B_C_D_
|0|1|0|1|
|1|0|0|1|
Where Column A is non-zero OR Column D is non-zero. I cannot think of any way to implement this with my current structure.
How can I filter table columns using OR logic as apposed to AND?
Just in case you might need that functionality wrapped up into some user-interface, you may go and check out this DataTables plug-in, in addition to conventional 'AND'-logic you may apply 'OR'-filtering.
Using your fiddle as a model I updated it to provide the functionality that I believe you want.
I extend the dataTables filtering on each click of a checkbox:
Fully integrated into fiddle: link