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.
Here
0
is the index of the column, if you want multiple columns to be not sorted, mention column index values seperated bycomma(,)
Using class:
For Single column sorting disable try this example :
For Multiple columns try this example: you just need to add column number. By default it's starting from 0
Here only
Column 3
worksThere are two ways, one is defined in html when you define table headers
Another way is using javascript, for example, you have table
then,
columnDefs
now accepts a class. I'd say this is the preferred method if you'd like to specify columns to disable in your markup:Then, in your JS: