How to sort "numerically"

How to sort "numerically"

fatshottyfatshotty Posts: 2Questions: 0Answers: 0
edited September 2013 in DataTables 1.9
Hello,

I need sort column as "numeric".
I used this code
[code]
// passing options in costructor
"aoColumnDefs": [
{ "sType": "numeric", "aTarget": [0] },
{ "sType": "numeric", "aTarget": [0] },
{ "sType": "numeric", "aTarget": [0] },
{ "sType": "numeric", "aTarget": [0] }
]
[/code]

Columns are sorted as "string"

Any help?

Replies

  • ThalliusThallius Posts: 31Questions: 4Answers: 0
    Why do you use same Target Column in each declaration? Copy&Paste Error?

    Regards

    Claus
  • fatshottyfatshotty Posts: 2Questions: 0Answers: 0
    I've found no documentation on how I can force to sort columns numerically.
    I found out, instead, the reason: I have columns containing numbers in "Italian" format (eg: 3.000,02). This causes DataTables script thinks it's a string.

    How can I use a custom sorting function?

    Thanks
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    You need to use a plug-in sorting method such as this: http://datatables.net/plug-ins/sorting#numeric_comma . I think it will need a small modification for your format (to remove the `.` characters, but that's how to do it.

    Allan
This discussion has been closed.