How can I remove ALL sort arrows from ALL columns?
How can I remove ALL sort arrows from ALL columns?
ckennedy65
Posts: 1Questions: 1Answers: 0
in General
I am trying to remove all of the sort arrows from the column headers when 'orderable' is set to false.
I included the following code in my datatable definition but an arrow continues to appear on the first column. I am not allowing sorting on any column, rather I'm using filtering and I don't want the sort arrows showing up at all.
columnDefs: [{
"orderable": false,
"targets": '_all'
}
Answers
The
columns.orderable
only affects the users ability to order columns. As stated in the docs theorder
option andorder()
API can affect the order. Thus the arrows still show. You can turn off all ordering withorder
likeorder: []
. Datatables will then show the table in the order of the data received.Kevin
You could inspect the sorting arrows and override the CSS settings. For example the default Datatables CSS to show the sorting icons is this:
You can change the background to something else if you wish.
Kevin
This needs a better solution. Kevin's solution to edit the css didn't work for me because I couldn't even find the snippets he pasted above. The only reference to table.dataTable thead was in css/plugins/datatables/dataTables.bootstrap.min.css and I removed the entire css from the page and it didn't change a thing
@leighJane The above CSS likely only works with the default Datatables styling. Depending on your goals you could simply set
ordering
to false. This will turn off all table ordering and the arrows won't show. If this doesn't help then please provide more information about your requirements.Kevin
Perfect!! That worked for me. Thanks Kevin
I removed this way in my css:
Thanks awariat!
That worked for me too, but I needed to add !important ...
I did notice that the small pop-up icon for adjusting column widths in the plug-in Daniel Hobi created no longer appears when hovering over column separator. Not sure which dt version it stopped appearing in. I know it worked in 1.11.3, but it does not work in 1.13.4.