I need to add a dropdown filter option in the database table, which displays records in the table based on the value selected. I checked latest documentation of DataTable and tried following :
$('#checkin-checkout-record-table').dataTable({
/* "dom": '<"toolbar">C<"clear">lfrtip<"clear">T',
tableTools: {
"sSwfPath": app.baseurl("/gbdportal/assets/js/libs/TableTools-2.2.4/swf/copy_csv_xls_pdf.swf"),
"aButtons": [{
"sExtends": "xls",
"oSelectorOpts": { filter: 'applied', order: 'current' }
}]
},*/
"bPaginate": true,
"bLengthChange": true,
"bFilter": true,
"bSort": true,
"bInfo": true,
// "order": [[0, 'asc'], [4, 'asc']],
"aLengthMenu": [50, 100],
"bAutoWidth": false,
initComplete: function () {
this.api().columns().every( function () {
var column = this;
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>' )
} );
} );
}
});
But filter dropdowns are not displayed. I think it might be due to version incompatibility. I am using 1.10.0-dev version.