Hi! I would like to know how can I make an auto-sizing of my table columns when I add search inputs into the table header.
By the time the column width is fixed at 169px (probably due to the search inputs) and I don't know how to resize it (so it can fit to my data).
Can you help me please?
$(document).ready(function() {
// Setup - add a text input to each header cell
$('#maTable thead .search').each( function () {
var title = $('#maTable thead .header_title').eq( $(this).index() ).text();
$(this).html( '<input type="text" placeholder="Search '+title+'"/>' );
} );
// DataTable
var table = $('#maTable').DataTable();
// Apply the search
table.columns().every( function () {
var that = this;
$( 'input', this.header() ).on( 'keyup change', function () {
that
.search( this.value )
.draw();
} );
} );
});