I have to order a table, but the numbers are coming in string and not int?
I have to order a table, but the numbers are coming in string and not int?

when i try to order the list looks this
1
10
11
12
2
20
21
22
3
30
and should loooks like this
1
2
3
10
11
and so long...
This question has accepted answers - jump to:
This discussion has been closed.
Answers
I hope you guys can help, bc im really stuck with this is what I try but is not working
DataTables tries to work out the type of the data, and apply the ordering appropriately. Your numbers are being displayed as strings - so that would suggest there's a non-numeric value in that column somewhere. You can force it to be numeric with
columns.type
set tonum
,Colin
they are coming from the database like strings, like this: '1', '2', '3'
Did you do that?
I try to do that but it doesnt work
Typically Datatables will take care of this for you through its type detection operation. Generally when the sorting behavior is not as expected there is otehr types of data in the column. Do you have
null
or some other type in the data? Can you provide a link to your page or a test case replicating the issue so we can take a look? If not maybe you can capture a debugger image for the developers to look at.https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case
Kevin