Add filter button to column header (specific column)

Add filter button to column header (specific column)

BusterenBusteren Posts: 52Questions: 17Answers: 4
edited January 2019 in Free community support

Hey there, so I have been looking at adding a button to filter the groups in a column, much like this:
https://datatables.net/examples/api/multi_filter_select.html
However, I want to add the button to the table column header (like where the sort button normally is). I have disabled sort for the column and then I was looking at this: https://datatables.net/reference/button/collection

I do have the Buttons JS included. Am I on the right track/any tips?
Mostly wonder what is the best way to include a custom button to the column header, as I am not 100% sure how to do this with the API.

This question has an accepted answers - jump to answer

Answers

  • BusterenBusteren Posts: 52Questions: 17Answers: 4

    Edit:

    More relevant: how to add a custom datatables button to the header of a column?

  • BusterenBusteren Posts: 52Questions: 17Answers: 4
    edited January 2019

    Solved by:

    initComplete: function() {
    var buttons = this.api().buttons().container();
    this.api().columns(1).every(function() {
          buttons.appendTo(this.header())
    }
    }
    

    Only thing is that the dropdown menu is behind the scrollBody...

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin
    Answer ✓
This discussion has been closed.