Search code examples
javascriptjquerydatatablesyadcfjquery-datatables-rails

DataTables + yadcf Add a Class to Filtered Column


Is there a way to add a class to filtered columns using yadcf?

As for now, When I filter a column on my table using a select box provided by yadcf, I can't seem to show that the column is filtered.

I want to add a class to the columns <th> so that I can style it to show my users that the corresponding column is filtered.

Thanks in advance.


Solution

  • Solved it using the .inuse class from yadcf. It's a class that yadcf applies on a filtered column. All I had to do was add $(".yadcf-filter.inuse").closest("th").addClass("bg-filter"); to my DataTables' drawCallback.