Data table filter
Data table filter
dzcatic
Posts: 1Questions: 1Answers: 0
I am using Individual column searching (select inputs). I was wondering is it possible to set filter for specific columns, not all of them?
Script I am using:
$(document).ready(function() {
$('#table').DataTable( {
initComplete: function () {
var api = this.api();
api.columns().indexes().flatten().each( function ( i ) {
var column = api.column( i );
var select = $('<select><option value=""></option></select>')
.appendTo( $(column.header()).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>' )
} );
} );
}
} );
} );
This discussion has been closed.