Globally set an orderable trait on a class
Globally set an orderable trait on a class
DanBridgeman
Posts: 3Questions: 1Answers: 0
I see how I can set columns with a class of 'no-sort', and then use columnDefs to make those columns not orderable when intializing each DataTable.
$('#example').DataTable({
columnDefs: [{ orderable: false, targets: 'no-sort' }],
});
But it would be much easier if I didn't have to set this on every DataTable. Is there something I could do globally to set any column with a 'no-sort' class not to be orderable by default?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Had to edit that....
Hi @DanBridgeman ,
Yep, you can easily tweak the defaults before initialising the table, something like this.
Cheers,
Colin
I took the portion that extends the DataTable defaults, and put that into a shared JavaScript file, and it works perfectly.
Many thanks @colin!