How to search across multiple columns?
How to search across multiple columns?
ibokat
Posts: 5Questions: 4Answers: 0
I want to search for a specific text in 2 different columns. Basically does the keyword "hamster" appear in column 1 or 6 and display the results. But I cannot figure out how that is working.
I have tried the following but it does not appear to work.
table.columns([1,6]).search("hamster").draw();
whats the right approach?
Answers
At this time that will result in a search on "hamster" on both columns 1 and 6 - an AND operation.
To do an OR search like that, you'd need to use a function (something which was introduced in the recently released 2.0.0). e.g.:
Note I've assumed the use of array based data there, change if you are using objects, and also I've used the new
search.fixed()
so the end user can still use the global search.Allan