Column Search API - Single Column, Multiple Queries
Column Search API - Single Column, Multiple Queries
I'm trying to use the column search API, and am able to do so successfully when searching for a single query, however I am trying to get it so that it returns columns that return EITHER value A or value B.
For example, a table is as follows:
ID | Group | Name |
---|---|---|
1 | Animals | Dog |
2 | Animals | Cat |
3 | Plants | Daffodil |
4 | Plants | Sunflower |
5 | Objects | Rock |
And I want to select any row that is part of either the group "Animals" or "Plants".
I have tried using the regex pattern, as follows:
dataTable.column(3).search("Animals|Plants", true).draw();
However this only returns plant rows.
Any help would be appreciated!
Thanks.
Answers
My mistake -- it is important that the smart search attribute is set to false for this to work.
Your code example works here:
http://live.datatables.net/viwuvuga/1/edit
I suggest adding the third parameter of
false
to turn off smart search. See thesearch()
docs for more details.Can yo provide a link to your page or a test case replicating the issue so we can help debug?
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin