How to highlight columns that have been filtered - Individual column searching
How to highlight columns that have been filtered - Individual column searching
Sorry I am not proving a link, I feel like this is probably extremely simple but I cannot get this to work.
I have several columns that can be individually filtered via text and was hoping to highlight columns that are actively being filtered.
Apologize in advance for my ignorance. Here I am just trying to test if it would work by clicking on the header and that wont work, but ideally it would highlight the column when any text is typed into the 'text box for the specific column.
table.api().columns().every( function () {
var that = this;
$( 'input', this.header() ).on( 'keyup change', function () {
if ( that.search() !== this.value ) {
that
.search( this.value )
.draw()
$('#example theader').on('click', 'td', function () {
var colIdx = table.cell(this).index().column;
$( table.column( colIdx ).nodes() ).addClass( 'highlight' );
}) ;
}
} );
$('input', this.header()).on('click', function(e) {
e.stopPropagation();
});
$('a.toggle-vis').on( 'click', function (e) {
e.preventDefault();
// Get the column API object
var column = table.column( $(this).attr('data-column') );
// Toggle the visibility
column.visible( ! column.visible() );
} );
} );
} );
Answers
Not sure if this search highlighter will do what you want:
https://datatables.net/blog/2017-01-19
It highlights text. I haven't tried it with column searches.
Kevin