Not disabling the first th column
Not disabling the first th column
xtremer360
Posts: 84Questions: 2Answers: 0
I'm trying to figure out why its not disabling the first column. Anyone know?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Any ideas on this?
I am clueless to why this is happening,
I'm trying to figure out why the first column is allowing for sorting when I gave the datatables modification to not be sortable. What am I doing wrong? I'm trying to get the first table heading to NOT be sortable.
$(document).ready(function(){
$('#basicTable').DataTable({
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [ "nosortable" ] }
]
});
});
http://jsfiddle.net/xtremer360/uwe4mp0d/
As answered on StackOverflow:
aTargets should be an array of the column numbers you want the definition to apply to:
http://jsfiddle.net/uwe4mp0d/1/
$(document).ready(function(){
$('#basicTable').DataTable({
"aoColumnDefs": [
{ "bSortable": false, "aTargets": [ 0, 3 ] }
]
});
});
As the documentation for
columns.orderable
notes that flag indicates only that the end user cannot sort the table using it. You can useorder()
to order the table by the column for example.As such, the default order of
[[0, 'desc']]
is being applied. Simply addorder: []
to the init for your table if you don't want a default order applied at all (usingorder
).I'll add a note to the documentation to state this explicitly.
Allan
Actually the
columnDefs.targets
can be a string as well to target columns with that class, which it looks like what @xtremer360 is doing.Allan
Ah, I didn't realize you could use a class for the target - thanks.
Looks like Allan has also already covered the update in stackoverflow with a new default order so you should be good to go now: http://jsfiddle.net/uwe4mp0d/2/