I am using datatable column select filter. In one of the column I have html link tag, this cause to show unsorted select options at the top
<th><a href="{{route('customer.information', $customer->id)}}">{{ $customer->name }}</a></th>
<script>
$(document).ready(function() {
$('#colSearch').DataTable( {
"order": [],
initComplete: function () {
this.api().columns([0,1,2,3,4,5,6]).every( function () {
var column = this;
var colTitle = this.header().innerHTML;
var select = $('<select><option value="">Select ' + colTitle + '</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 ) {
var val = $('<div/>').html(d).text();
select.append( '<option value="' + val + '">' + val + '</option>' );
} );
} );
}
} );
} );
</script>
You can check the example datatable http://live.datatables.net/cikaqoxe/1/