API fnFilter - filter using an OR on a single column?
API fnFilter - filter using an OR on a single column?
I'm using the fnFilter API call to filter on a column. However, I need to equivalent of an OR. I have two check boxes the user can select/deselect to filter on status; Complete and Pending. If the Complete check box is deselected I want to filter out Complete items. If Complete is checked, I want to include them. Is this possible? Thanks
This discussion has been closed.
Replies
so:
[code]oTable.fnFilter("Complete|Pending", iColumn, true); // param 3 is whether or not to use reg expression[/code]
of course if you're using server side processing, your server script will need to detect the bRegExp for that column and process it. if you need that, let me know.
I have a search text field, then 3 select option dropdowns in a row along the top of the datatable.
The filter works fine and it filters the respective columns. What I want though, is the second select option dropdown (list of locations) to fnFilter specific values (France OR Italy) sometimes and multiple values (France AND Italy) other times.
Is this possible? A clearer example is below this code...
Snippet of current HTML code
[code]
location
England
Bedfordshire
Buckinghamshire
Hertfordshire
UAE
Dubai
Abu Dhabi
EU
France
Germany
Italy
[/code]
Example:
If Dubai is selected, the column 2 tables with Dubai in are filtered (as normal), if UAE is selected, column 2 tables with either Dubai or Abu Dhabi are filtered. Likewise for the EU and England; EU will show all tables with either France or Germany or Italy in.
Snippet of current JS in
[code]
$('select#industries').change( function() {
oTable.fnFilter( $(this).val(), 1 );
} );
$('select#location').change( function() {
oTable.fnFilter( $(this).val(), 2 );
// oTable.fnFilter("Dubai|Abu Dhabi", 2, true);
} );
$('select#type').change( function() {
oTable.fnFilter( $(this).val(), 3 );
} );
[/code]
Any help appreciated.