columnDefs target fuction only targets the first column
columnDefs target fuction only targets the first column
![jaco](https://secure.gravatar.com/avatar/2555341a7c438f22c532bfcb3f7f89b1/?default=https%3A%2F%2Fvanillicon.com%2F2555341a7c438f22c532bfcb3f7f89b1_200.png&rating=g&size=120)
"columnDefs": [{
type: 'num-html',
targets: 4
}]
This is the code I use but when I run the website it shows that the first column is sorted and not the 4 column.
Answers
By default the first column will be the one that's sorted - if you want to change that, use
order
.Colin
If I use the order method, the numbers don't order correct . They order 1, 10, 2, 3, 33, 4 instead of 1, 2, 3, 4, 10, 33
It is not recommended to set the
columns.type
as Datatables will perform auto-detection of the data type in the column. Try removing that code. If it still sorts in the wrong order then Datatables is detecting the column as a string, not numeric, column. This means there is something other than numbers in the column.Please post a link to your page or a test case replicating the issue so we can help debug.
https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin