Hi, I'm trying to implement column filter but it is not working.
Hi, I'm trying to implement column filter but it is not working.
(Start code)
$(document).ready(function() {
$('#data-table').DataTable( {
"sPaginationType": "full_numbers",
"bStateSave": true,
"ajax": "http://beta.json-generator.com/api/json/get/41ZMGWS17",
"columns" : [
{ "data" : "name" },
{ "data" : "gender" },
{ "data" : "designation" }
],
"initComplete": function () {
this.api().columns().every( function () {
var column = this;
var select = $('<select><option value=""></option></select>')
.appendTo( $(column.footer()).each() )
.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>' )
} );
} );
},
} );
} );
(End code)
Answers
try https://yadcf-showcase.appspot.com/
Thanks for your question - however, per the forum rules can you link to a test case showing the issue please. This will allow the issue to be debugged.
Information on how to create a test page, if you can't provide a link to your own page can be found here.
Thanks,
Allan