Filtering the table based on external controls

Filtering the table based on external controls

maliwikmaliwik Posts: 55Questions: 5Answers: 1
edited January 2012 in General
I have a table of businesses (with row grouping, expandable details, etc) and each business can have up to 5 business types. I want to create a group of five select boxes with business types and I want to be able to filter a column in the table based on those types. So if someone selects Travel from one box and Tourism from another, it'll show only businesses that have both the Travel and Tourism business type. All of a business' 5 types are listed in one column.

Is this possible?

Replies

  • maliwikmaliwik Posts: 55Questions: 5Answers: 1
    Updating this post. I want to do things a little differently. If what I wrote above isn't possible, is there a way to filter columns based on external controls?

    Instead of having them in the table, have a couple select boxes above the table that would filter certain columns like City, State, and County. Would anyone know how I might go about filtering a column with the onChange event of a select box?
  • allanallan Posts: 63,538Questions: 1Answers: 10,476 Site admin
    > is there a way to filter columns based on external controls?

    Yes - use fnFilter . Then you can use any control you want to activate any filter in any way you want.

    Allan
  • allanallan Posts: 63,538Questions: 1Answers: 10,476 Site admin
    Example of fnFilter for 'change' in a select menu: http://datatables.net/release-datatables/examples/api/multi_filter_select.html

    Allan
  • maliwikmaliwik Posts: 55Questions: 5Answers: 1
    Thanks Allan! Just found that right as you posted.

    Do you think there's a way to tie that into my original predicament of having 5 type select boxes filtering on one column? I've managed to get it so it'll filter that column when you select one, and then when you select another type from a different box it'll filter the currently shown rows by the additional type. The only problem is if I try to set the second box back to normal it'll show all of the rows and won't keep the original type filter.
  • maliwikmaliwik Posts: 55Questions: 5Answers: 1
    Basically I want to take into account all select boxes when filtering the table.
  • maliwikmaliwik Posts: 55Questions: 5Answers: 1
    I figured out how to do it. On the server side I created five columns with all five of the business' types in each one and hid four of them. Then I made the first box search the first column, second box searches the second one, and so on. It's kind of clunky but it'll have to do for now. Haven't noticed any slowdown whatsoever doing it this way.
This discussion has been closed.