I am displaying data table in the web page, I want to add an additional filter to get results based on clinic name
I got data table displayed and all other functionalities like searching, sorting work fine but column filtering is not working
Following is my code
$(document).ready(function() { $('#example').DataTable( { 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>' ) } ); } ); } } ); } );
I refereed this from [https://datatables.net/examples/api/multi_filter_select.html]
But why values are not showing,
Is there are any other options to add Select drop-down to show values of clinic name from PHP database, and on clicking that I want to filter the data on the table
Advertisement
Answer
Please check whether your table have <tfoot>
this require tfoot element to works