how to do a multifilter?
how to do a multifilter?
Hi all,
I have a question regarding filtering.
fnFilter will do the job for single field filter. However, i am looking to filter based on several field at once.
I'm thinking of
1. generating the condition using javascript, for example " AND age>=30 AND name LIKE 'Ja%' "
2. passing the condition to the server page
3. at the server page, the condition is appended to the select, example "SELECT * FROM member WHERE 1=1 AND age>=30 AND name LIKE 'Ja%' "
4. the query then executed and the result is passed back to datatables.
is their any way to manage this? or other way is also welcomed
thanks before :)
I have a question regarding filtering.
fnFilter will do the job for single field filter. However, i am looking to filter based on several field at once.
I'm thinking of
1. generating the condition using javascript, for example " AND age>=30 AND name LIKE 'Ja%' "
2. passing the condition to the server page
3. at the server page, the condition is appended to the select, example "SELECT * FROM member WHERE 1=1 AND age>=30 AND name LIKE 'Ja%' "
4. the query then executed and the result is passed back to datatables.
is their any way to manage this? or other way is also welcomed
thanks before :)
This discussion has been closed.
Replies
What you can do, if you want to filter on a single column, is to use fnFilter with a column indicator in the second column ( http://datatables.net/api#fnFilter ). That will do AND based filtering. If you want to do things like >= then you need to use custom filtering: http://datatables.net/examples/plug-ins/range_filtering.html (assuming you are doing it on the client-side - if you are using server-side processing, then you just alter your query as needed).
Individual column filtering example (it might be useful): http://datatables.net/examples/api/multi_filter.html
Allan
Thanks for the response. Your reply are helpful.
The datatables is really useful :D
thanks a lot!