Reputation: 2476
I am using datatable API. Here, I want to hide sorting arrows for some specific columns. How do I do that ?
I tried this code but didn't work.
$('#example').dataTable( {
"columnDefs": [
{ "orderable": false, "targets": 0 }
]
});
Upvotes: 1
Views: 539
Reputation: 11466
If you want to target a specific column, multiple columns, or all columns, use the aTargets
property instead your "targets"
. The aTargets
property is an array to target one of your columns and it can be:
aTargets : [0]
- first column from the left aTargets : [1]
- second column, etc... aTargets: ['_all']
- select all columnsSo if you want to hide sorting arrow for let's say first column, use this code:
$(document).ready(function() {
$('#example').DataTable( {
aoColumnDefs : [ {
orderable : false, aTargets : [0]
}],
order: []
} );
} );
During initialization in example we don't want to apply ordering, so we set order property empty:
order: []
I choose one table from datatables examples and put all this in working example: jsFiddle
Upvotes: 4