how to get column detected as numeric when using ajax + sort + orthogonal data?

how to get column detected as numeric when using ajax + sort + orthogonal data?

jtorontojtoronto Posts: 2Questions: 1Answers: 0

I have a column:

JSON:

"disk_usage": {
"display": "<b>10 MB</b>",
"bytes": "10000000"
},

The column has a sort on it:

JQUERY:

{ data: {
_: "disk_usage.display",
sort: "disk_usage.bytes"
} },

But no matter what I do, it sorts as a string, instead of numeric. Doesn't the auto-detect look at the sort column (which is all numeric data)? What could be causing this.

I also tried using "stype" but it threw a bunch of errors.

Any ideas?

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,356Questions: 1Answers: 10,444 Site admin
    Answer ✓

    You need to add a type option as well and tell it to use the bytes since the type detection is currently running on the HTML string.

    Try:

    {
      data: 'disk_usage',
      render: {
        _: 'display',
        sort: 'bytes',
        type: 'bytes'
      }
    }
    

    If that doesn't work, please link to a page showing the issue.

    Allan

  • jtorontojtoronto Posts: 2Questions: 1Answers: 0

    Worked like a charm :-)

    Thank-you for the quick response and help.

This discussion has been closed.