column filtering using dropdown - how to confine to some columns only
column filtering using dropdown - how to confine to some columns only
hbanaharis
Posts: 32Questions: 14Answers: 3
in Editor
Im using this code to generate a dropdown filter for each column.
this.api().columns().every( function () {
var column = $(this).class('filterhead');
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>' )
} );
} );
How can I apply it only to selected columns ie based on the footer th class?
This discussion has been closed.
Answers
use this.api().columns( a )
where a = sequence of columns
eg if columns 3,4 and 5 then a = '3,4,5'