API fnFilter - filter using an OR on a single column?

API fnFilter - filter using an OR on a single column?

stodgestodge Posts: 10Questions: 1Answers: 0
edited November 2011 in General
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

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    edited November 2011
    if you use regular expression, "|" means "OR"

    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.
  • stodgestodge Posts: 10Questions: 1Answers: 0
    Hmm good point, I hadn't thought of that. I'll check my server side code to see if I can do that. Obvious really! Thanks again.
  • drebbindrebbin Posts: 1Questions: 0Answers: 0
    Hi guys, hopefully you don't mind me steeling this post to get some help. I'm looking for a similar solution. I've managed to get quite far without bothering anyone, but now, I'm afraid, I need help. :-s

    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.
This discussion has been closed.