I have created a basic datatable, now I want to customize it by adding filter in every column. I already got the solution from: https://www.datatables.net/examples/api/multi_filter_select.html
BUT, where I should put the additional code? I have tried copy paste the code in jquery.datatables.js and also try to put in new js file, neither both of them worked.
Please kindly help me...
code that I got from datatables website:
$(document).ready(function() {
$('#example').DataTable( {
initComplete: function () {
this.api().columns().every( function () {
var column = this;
var select = $('<select><option value=""></option></select>')
.appendTo( $(column.footer()).empty() )
.on( 'change', function () {
var val = $.fn.dataTable.util.escapeRegex(
$(this).val()
);
column
.search( val ? '^'+val+'$' : '', true, false )
.draw();
} );
column.data().unique().sort().each( function ( d, j ) {
select.append( '<option value="'+d+'">'+d+'</option>' )
} );
} );
}
} );
} );
<script>tag in the same HTML file and use above code if your HTML has a <table> tag with all the data rows after document load.