jQuery Datatable disable sorting for one column
Sometimes we want to remove Sorting in datatable so today we will learn how to Disable Sorting for any specific column in simple steps.
jQuery datatable provides columnDefs option that we can use to remove sorting (asc/desc) from any column .
Please use below code
var oTable= $('#idDataTable').DataTable({
"order": [[ 3, "asc" ]],
'columnDefs': [{
"targets": [0],
"orderable": false
}]
});
So in above code we mentioned targets as 0, that means it will disable ascending descending option for first column, you can disable sorting for multiple columns by separating them with comma(,)
Source code for disable sorting for multiple column.
var oTable= $('#idDataTable').DataTable({
"order": [[ 3, "asc" ]],
'columnDefs': [{
"targets": [0,1,2],
"orderable": false
}]
});
Important Links:
jQuery Datatable disable sorting for one column or multiple columns
This post first appeared on Thecoderain PHP,wordpress,cakephp,codeigniter,js, Jquery, Ajax Free Tutorials, please read the originial post: here