Why does my Table sort those Numbers in a wrong order?

Why does my Table sort those Numbers in a wrong order?

proairproair Posts: 5Questions: 0Answers: 0
edited October 2009 in General
check out the screenshot
http://img25.imageshack.us/img25/5831/datatabel.jpg

my td tag:
[code]<? echo number_format(round($mynumber,0),0,',', '.'); ?>[/code]

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Hi proair,

    The reason that this would occur is if you either have a blank entry in the column somewhere (i.e. the cell is empty), or if you have non-numeric data (including white space) in the column (it doesn't look like it from your PHP statement though, so I'd guess the former). Either of this will cause DataTables number detection to trip up and have it treat the column as a string.

    Regards,
    Allan
  • proairproair Posts: 5Questions: 0Answers: 0
    hello allan,
    thanks for your fast answer.

    i had define the column as "numeric" and the php statement will turn every var in a number

    [code]
    $('#range_table').dataTable({
    "sDom": 'rtip',
    "aoColumns": [
    { "sType": "string" },
    { "sType": "numeric"}
    ],
    "aaSorting": [[1, 'desc']],
    "oLanguage": {
    "sUrl": "../js/de_DE.txt"
    },
    });
    [/code]

    so i am not sure why this happend
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Hi proair,

    Did it work when you defined the sType as 'numeric'? That's the "hit it with a hammer" approach :-). If you use Firebug to inspect the live DOM, perhaps that might shed some light on why DataTables is rejecting it. Failing that, then some debug in the auto detect function might be called for.

    Regards,
    Allan
  • proairproair Posts: 5Questions: 0Answers: 0
    hey allan,

    tahnks for your answer.

    i inspect the dom but i am not sure if this is right.

    please check out the screenshot
    http://img202.imageshack.us/img202/4752/datatabedoml.jpg
  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    Hi proair,

    The two numbers you have in those cells certainly look correct and should be identified as numbers by DataTables. Is accurate for all rows in your table (i.e. no empty values, no while space, no commas in larger numbers for formatting etc)?

    Thanks,
    Allan
This discussion has been closed.