Reputation: 352
I am using bootstrap datatable, when I click on sorting icon on second column then only it removes icon from first column, otherwise it appears on page load, I have written column number to remove from ordering in code but not working.
$('#example').DataTable( {
"columnDefs": [ {
"targets": [0,1],
"orderable": false
},
{ "width": "8%", "targets": 0 },
{ "width": "13%", "targets": 1 } ],
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>' )
} );
} );
}
});
Upvotes: 0
Views: 450
Reputation: 101
Datatables uses the first column as ordering by default, and thus renders the icon that states which column is the one providing the ordering. If you want to remove it then you have to provide an explicit ordering in your configuration, such as:
order: [[1, 'asc']],
which will use the second column as default ordering.
Upvotes: 1