How to move filters from tfoot?

How to move filters from tfoot?

PallarPallar Posts: 2Questions: 1Answers: 0

Hi,

I have a simple question about dataTables and "Individual column searching (select)" in particular.
Explain it to me like I am 5 - how to move filters (selects) from bottom of my filtered table from footer (<tfoot>) to somewhere else in the DOM? I am a JS beginner, so no shortcuts please, step-by-step explanation if you please.
Thanks!

Answers

  • allanallan Posts: 62,301Questions: 1Answers: 10,216 Site admin

    In the example you mention - this is the key line:

    .appendTo( $(column.footer()).empty() )

    Change it to append the element to wherever you want it to appear in your document.

    Allan

  • PallarPallar Posts: 2Questions: 1Answers: 0

    Allan - thank you! I would buy you a decent beer for that! I looked at that code and didn't see that, and now - it's quite obvious.

    Could you tell me how to pick couple of columns to create "select" filters? Don't want to generate them for all columns, just column #2 and #3 for example. Where I need to specify which columns I am interested in?

  • allanallan Posts: 62,301Questions: 1Answers: 10,216 Site admin

    Funnily enough, an ale at 11am on a Monday morning is strangely appealing ;-)

    Could you tell me how to pick couple of columns to create "select" filters?

    Refering to the same example, on line 4 we have:

    this.api().columns().every( function () {
    

    That is using columns() to select the column. By default it selects all but the column-selector option can be used to refine that.

    Allan

This discussion has been closed.