Filtering - Input as array
Filtering - Input as array
Hi,
first of all I have to say that DataTables is an excellent framework. I really like it and I'm faszinated of its features.
Great job!!!
So here's my problem:
I'm trying to filter a table with multiple selections. (So the filter value input is probabbly an array)
The user can choose multiple locations via a checkbox and these locations should be filtered and displayed.
So the locations must be combined with the logical operator OR.
i.e. show results from LocationA OR LocationB
How can I do that?
I tried to do this with regular expressions. Using the filter string "LoactionA|LocationB" - that doesn't worked.
I tried also to use such regEx filter at the example at http://www.datatables.net/examples/api/regex.html
I also doesn't worked.
Do I have to write a custom filter?
Could you please help me with that problem.
Thanks :)
first of all I have to say that DataTables is an excellent framework. I really like it and I'm faszinated of its features.
Great job!!!
So here's my problem:
I'm trying to filter a table with multiple selections. (So the filter value input is probabbly an array)
The user can choose multiple locations via a checkbox and these locations should be filtered and displayed.
So the locations must be combined with the logical operator OR.
i.e. show results from LocationA OR LocationB
How can I do that?
I tried to do this with regular expressions. Using the filter string "LoactionA|LocationB" - that doesn't worked.
I tried also to use such regEx filter at the example at http://www.datatables.net/examples/api/regex.html
I also doesn't worked.
Do I have to write a custom filter?
Could you please help me with that problem.
Thanks :)
This discussion has been closed.
Replies
I tried it at the example page with the following inputs:
Fire.*|Misc -> works well (because both occures in different columns ["Browsers" and "Rendering engine"])
Fire.*|Camino.* -> doesn't work (both entries are in the same column ["Browsers"])
Is it a bug?
How to solve this problem?
I want to use the regular expression to display some rows which have values specified on my search box. I have the same issue, do you have found a solution ?
Thanks
Louis
I think I'm doing what you are trying to do. What I'm doing is creating a string from a set of checkboxes that looks like value1|value2 and then running fnFilter, but making sure not to escape regex:
[code]
...
var values = "value1|value2";
var filterColumn = 1;
var escapeRegex = false;
oTable.fnFilter(values, filterColumn, escapeRegex)
[/code]
Thanks for your help.
@Pimperish: yes, thanks. It was what I was looking for. Meanwhile I also found this solution as well. Anyway thanks for sharing your code :)
@Allserv: the RegEx seems to have a problem when escaping the string and if you leave the column blank. I added both and it worked for my problem. But if you have to filter through various columns it doesn't work. Also if you are using special characters it doesn't work.
I have tried to set the filter column after pimperish's response and all works now. I think too is a little bug in datatable script when I set filter's column to null.
Thanks.
Louis