Move Select2 search inputs from footer to a sidebar

Move Select2 search inputs from footer to a sidebar

heath22heath22 Posts: 17Questions: 5Answers: 0

The table I have has around 30 columns.
It's easier to have all search filters in a sidebar visible at once than in the footer where you have to scroll the table to the column needed.

I've tried to use fnFilter and construct them manually. I tried to clone them, nothing works.

Suggestions?

Here's my case example:

http://live.datatables.net/mewewuya/1/edit

Thank you.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,166Questions: 26Answers: 4,921
    Answer ✓

    Instead of the column footer as the selector when creating the selects in this statement:

                    var select = $('<select id="' + title + '" class="select2" ></select>')
                        .appendTo( $(column.footer()).empty() )
    

    You need to use a selector in your sidebar. I added a div to the sidebar and appended the selects to that in this example:
    http://live.datatables.net/mewewuya/2/edit

    Everything else is the same. You will need to make changes to pretty up the sidebar and make it look like you want. The example is merely to give you an idea of what to do.

    Kevin

  • heath22heath22 Posts: 17Questions: 5Answers: 0

    @kthorngren , thank you!

This discussion has been closed.