multiple filters on same column

multiple filters on same column

rfitzwaterrfitzwater Posts: 57Questions: 5Answers: 1
edited October 2011 in DataTables 1.8
Is it possible to have multiple filters on the same column? For example, if a table has a column or browsers, and I had the individual column search enabled, I would like to enter something like (Safari AND Firefox) or (Safari, Firefox). Currently, you can only enter one search criteria for each column to my knowledge.

Thanks,

-Rhon

Replies

  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    yes. easiest way is to use the built in regular expression matching and use the "|" (OR) operator

    http://www.datatables.net/release-datatables/examples/api/regex.html

    try putting "firefox|netscape" into column 2 filter and enable "Treat as regex"

    you don't have to have your users use the "|" char. you could take their input, then treat white space as a breaking point, replace with "|" chars, for instance.
  • rfitzwaterrfitzwater Posts: 57Questions: 5Answers: 1
    How/where can I change the "|" char so it works with whitespace " " instead?
  • fbasfbas Posts: 1,094Questions: 4Answers: 0
    look through the source of the link I posted above, but before you pass the string to the fnFilter, break it up or replace the space char with "|"

    [code]
    mysearchstring = mysearchstring.replace(/\s+/g, "|"); // replace white space with "|" char
    [/code]
  • rfitzwaterrfitzwater Posts: 57Questions: 5Answers: 1
    Thanks!
This discussion has been closed.