Add filter button to column header (specific column)

Add filter button to column header (specific column)

BusterenBusteren Posts: 41Questions: 14Answers: 4
edited January 11 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: 41Questions: 14Answers: 4

    Edit:

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

  • BusterenBusteren Posts: 41Questions: 14Answers: 4
    edited January 11

    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: 49,321Questions: 1Answers: 7,239 Site admin
    Answer ✓
Sign In or Register to comment.