number sort

number sort

triumdhtriumdh Posts: 9Questions: 0Answers: 0
edited March 2012 in DataTables 1.9
Hello,

I have a numbers column ranging from 400 to 1200. No other data. The sort option will bring up 1000 before 400 in the ascending and 999 first in decending. I see that it is reading the first number only when defining the sort order. When I add
[code]
{ "sType": "numeric", "aTargets": [ 4 ] }
[/code]
the numbers in the second column will change leaving all other results unchanged.
Do I have an error in the above code or do I need a pluggin when I use numeric data.
I also stripped out any null entries in the query.
All other columns sort correctly apart from the date which is in mm/dd/yyyy format.

Replies

  • allanallan Posts: 63,491Questions: 1Answers: 10,470 Site admin
    edited March 2012
    Can you run your table through the debugger please: http://debug.datatables.net - that will let me see what is going on.

    Allan
  • triumdhtriumdh Posts: 9Questions: 0Answers: 0
    Allen,

    Thank you for your reply.
    The code is uvujub.

    Martin
  • allanallan Posts: 63,491Questions: 1Answers: 10,470 Site admin
    You have non-numeric data in all of your columns - more specifically you've got HTML. So what DataTables is doing is stripping the HTML and then string sorting. What you need to do is use the HTML numeric plug-in: http://datatables.net/plug-ins/sorting#numbers_html and type detection plug-in: http://datatables.net/plug-ins/type-detection#numbers_html

    Allan
  • triumdhtriumdh Posts: 9Questions: 0Answers: 0
    I replaced the html div's used to center columns within the cells with the DATA which then removed the html and then the sort worked.

    Thank you for your time and patience
This discussion has been closed.