I am using the jQuery datatables plugin to sort the table fields. My question is how do I disable sorting for a particular column? I have tried with the following code, but it did not work:
"aoColumns": [
{ "bSearchable": false },
null
]
I have also tried the following code:
"aoColumnDefs": [
{ "bSearchable": false, "aTargets": [ 1 ] }
]
but this still did not produce the desired results.
you can also use negative index like this:
Use the following code to disable ordering on first column:
To disable default ordering, you can also use:
Here is the answer !
targets
is the column number, it starts from 0As of 1.10.5, simply include
in columnDefs and target your column with
Table should like like:
set class "no-sort" in th of the table then add css .no-sort { pointer-events: none !important; cursor: default !important;background-image: none !important; } by this it will hide the arrow updown and disble event in the head.
Here is what you can use to disable certain column to be disabled:
So all you have to do is add the "orderable": false to the column you don't want to be sortable.