Creation of dynamic drop down filter per column

Creation of dynamic drop down filter per column

jplechenejplechene Posts: 1Questions: 0Answers: 0
edited May 2009 in Plug-ins
Hello,

First thanks for such a great, and easy to use, JQuery module.
Now comes the real stuff: I'm looking for a feature which would dynamically build a dropdown list, containing unique values, for each viewable column of a table.

According to you, what would be the best approach to build such feature ?
Embedded the code inside the datatable's code (which is what I have currently done) or as an external plugin (but I don't know how to pass the initialisation parameters during the table's creation in such a case as those dropdown need to be built during the datatable initialisation ?)

I can provide you with the current implementation if you want, but this has been made directly inside the datatable's code, so I don't know if this is the best approach if someone else is looking for the same kind of possibilities.

Any advice would be appreciated here.

Thanks,

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,470 Site admin
    Hi jplechene,

    If I understand correctly what you want is basically what is shown in this example http://datatables.net/examples/example_multi_filter.html , but with drop down menus rather than search input boxes. Is that right?

    If so, then what to do is create the select boxes in the footer before you initialise the DataTable. Run through the DOM with a script which pulls out each of the values in the table (or however you want to get the values) and base your drop down menu on this (just a simple ). Once done, add a 'change' event handler to your drop down menus such that whenever the selected value changes, the table's filtering is invoked - just like in the example ('change' rather than 'keyup' though).

    Hope that helps,
    Allan
  • CHgsdCHgsd Posts: 25Questions: 0Answers: 0
    For those finding this thread and having missed the example with select dropdowns as I did, here it is:
    http://www.datatables.net/examples/api/multi_filter_select.html

    (I had no part in that, just repasting the link to "answer" this thread)
This discussion has been closed.