how to do a multifilter?

how to do a multifilter?

mixcalmixcal Posts: 7Questions: 0Answers: 0
edited May 2010 in General
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 :)

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    edited May 2010
    The default filtering in DataTables is to do "global" filtering - which is on all columns (although of course it depends how it is implemented on the server-side!).

    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
  • mixcalmixcal Posts: 7Questions: 0Answers: 0
    Hi Allan,

    Thanks for the response. Your reply are helpful.
    The datatables is really useful :D
    thanks a lot!
This discussion has been closed.