I am using datatable plugin with individual column filters, I found this is a great plugin but it's only filtering table data not the values in columns filter dropdown after selection of the column filter.
Here I am looking, when I select one column filter then it will also redraw other column filters instead of showing all the values in that column of entire table.
I am looking like in this example
If I selected Singapore from Office column filter it's showing 4 records with 4 different positions, I am expecting only those 4 values in Position column filter. But it's giving all unique values of entire table.
Can someone help me how can i achieve this?
I have my code something as below:
$('#myTableId').DataTable( {
colReorder : true,
initComplete: function () {
this.api().columns([0,1]).every( function () {
var column = this;
var select = $('<select><option value="">All</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>' )
} );
} );
}
} );