I am using the jQuery DataTables plugin.
Is there a way I can get rid of the little arrows they display in the headers to indicate sorting options ? I would like to keep the functionality that by click on a header it sorts by this column, I just dont want to display the arrow icons as they change the layout of my column headers.
Firebug shows my headers as follows:
<th class="sorting" role="columnheader" tabindex="0" aria-controls="myTable" rowspan="1" colspan="1" style="width: 151px;" aria-label="Category: activate to sort column ascending">Category</th>
You can e.g. set style="display:none;" to the arrow element. You can set it programmatically using JavaScript or you can use CSS class.
The existing answers are using legacy DataTables syntax. Versions 1.10+ should use the following syntax: $('table'). dataTable({ "pageLength": -1, //display all records "order": [[ 0, "desc" ]] // Sort by first column descending });
The icons is defined as background : url(..)
on the CSS classes. Disable them by :
.sorting, .sorting_asc, .sorting_desc { background : none; }
see jsfiddle -> http://jsfiddle.net/5V2Dx/ Note : This solution is for datatables 1.9.x!!
Update. When using datatables 1.10.x, the CSS for resetting the header icons is a little bit different :
table.dataTable thead .sorting, table.dataTable thead .sorting_asc, table.dataTable thead .sorting_desc { background : none; }
see -> http://jsfiddle.net/kqpv3ub9/ (updated demo is using dataTables 1.10.11)
None of the presented solutions worked for me. But I have just found this one;
.dataTable > thead > tr > th[class*="sort"]:before, .dataTable > thead > tr > th[class*="sort"]:after { content: "" !important; }
PS.: DataTables version "datatables": "~1.10.2"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With