Logical OR filter for one specific column

Logical OR filter for one specific column

WornWorn Posts: 7Questions: 0Answers: 0
edited November 2012 in General
Hi,

I was looking for a solution to implement a logical OR filter for one specific column. So if there is a column NAME then I would like to have a searchbox where I can enter different names and all rows that match one of the entered names will stay visible. I think this is an easy thing to do but blame me... I did´n find the easy solution yet :-(. Can somebody point me to the right information on how to achive this?

Maybe this is also possible to realize with the main search box. But this should also stay able to filter the other columns too (but one spec. with OR).

Thanks in advance
Worn

Replies

  • allanallan Posts: 63,532Questions: 1Answers: 10,475 Site admin
    An OR filter for a single column can be done with a regex and telling fnFilter that you are passing in a regex - 3rd parameter (also best to disable smart filtering - 4th parameter - when you pass in your own regex).

    Allan
  • WornWorn Posts: 7Questions: 0Answers: 0
    Hi,

    thanks for your quick reply! I have an additional question to that. Is there a way to enable this for the global searchBox? So to limit seach to one column and set it to regex search style so that I could search for names like name1|name2|name3? Otherwise I would have to replace the global searchbox with my own or add another searchbox? I know there is bFilter that could be set to false, then the searchbox disapperars but then something with DataTable.defaults.sDom has to be done? I haven´t found a hint how to use this DataTable.defaults.sDom to remain the filter feature but replace the searchbox.

    Thank you!
    Worn
  • allanallan Posts: 63,532Questions: 1Answers: 10,475 Site admin
    > Otherwise I would have to replace the global searchbox with my own or add another searchbox?

    This. You simply put an input element somewhere and bind fnFilter to it.

    > I know there is bFilter that could be set to false, then the searchbox disapperars but then something with DataTable.defaults.sDom has to be done

    If you want filtering to be possible, leave bFilter as it's default `true` value. Drop the `f` option from sDom to not display the default global filter.

    Allan
  • WornWorn Posts: 7Questions: 0Answers: 0
    Hi allan,

    thanks again. I guess I have enough information to start filtering now ;-). By the way thanks for that awesome plugin! Definetly one of the best jQuery-Plugins ever!

    Worn
  • allanallan Posts: 63,532Questions: 1Answers: 10,475 Site admin
    Thanks very much :-)

    Allan
This discussion has been closed.