search in Header
search in Header
antoniocib
Posts: 277Questions: 62Answers: 1
$('#scadenze thead th').each( function () {
var title = $(this).text();
$(this).html( '<input type="text" style="text-align:center ; width:100%" placeholder="'+title+'" />' );
} );
var table = $('#scadenze').DataTable();
table.columns().every( function () {
var that = this;
$( 'input', this.header() ).on( 'keyup change clear', function () {
if ( that.search() !== this.value ) {
that
.search( this.value )
draw();
}
} );
table.on('select deselect', function () {
table.draw(false);
});
} );
I have implemented the search in the header of the table but I don't want it for all the columns how can I customize it?
This question has an accepted answers - jump to answer
Answers
by assigning a class to the respective td element and then using the class in your JS.
@rf1234 can you explain it better?
You assign the class to the columns you want column search to work and you don't assign the class to those columns that shouldn't be column searchable.