Globally set an orderable trait on a class
Globally set an orderable trait on a class
![DanBridgeman](https://secure.gravatar.com/avatar/4018bb3937f3dec672b9fb45c2dfda7e/?default=https%3A%2F%2Fvanillicon.com%2F4018bb3937f3dec672b9fb45c2dfda7e_200.png&rating=g&size=120)
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!