I'm using the following code to add filtering on one column in my datatable:
"initComplete": function () {
this.api().column(4).every( function () {
var column = this;
var select = jQuery('<select><option value=""></option></select>')
.appendTo( jQuery(column.header()).empty() )
.on( 'change', function () {
var val = jQuery.fn.dataTable.util.escapeRegex(
jQuery(this).val()
);
column
.search( val ? '^'+val+'$' : '', true, false )
.draw();
});
column.data().unique().sort().each( function ( d, j ) {
select.append( '<option value="'+d+'">'+d+'</option>' )
});
});
}
I was wondering 1) if there is a way to add an 'All' option to the filter rather than just the blank filter selection option and 2) if there is a way to add a label to the left of the filter dropdown, e.g., Type?
Thanks!