Ordering more than 3 digits

Ordering more than 3 digits

karliekarlie Posts: 83Questions: 17Answers: 0

Hi, I have a column containing only numbers. I can get this to order accurately, but only with 3 digits. As soon as it encounters 4 digits the ordering goes wrong. I'm using server side.

Any ideas?

Answers

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    it is being sorted as a string not a number. Number of digits has nothing to do with the issue.

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    We probably need to see your c ode. We need to figure out why its not automatically detecting its type as number.

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    Likely it contains non-numeric data somewhere in the column, or you are using server-side processing and the sort is string based.

    @bindrid - I read "We probably need to see your c ode." as that the original author was writing code in C for DataTables. That woke me up properly on a Monday morning :).

    Allan

  • bindridbindrid Posts: 730Questions: 0Answers: 119

    I can't type a simple sentence. Just imagine what my code looks like :blush:

  • karliekarlie Posts: 83Questions: 17Answers: 0
    edited May 2018

    Hi, I exported my database column and I found a rogue underscore in there, however, the problem is still there with that removed

    I have tried setting my column setting as:

                    {
                        "data": "number_column",
                        "orderable": true,
                        "searchable": false,
                        "type": 'num'
                    },
    

    And I have tried setting my column def as

    { "type": "num", "targets": 5 },
    

    I've searched for leading and trailing spaces too

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    "type": 'num'

    Remove that. If DataTables isn't automatically detected it as a number type, the built in number sorting won't work.

    Sort the data in both directions. It might show a rouge character.

    Allan

  • tangerinetangerine Posts: 3,342Questions: 35Answers: 394

    It might show a rouge character.

    If your data is wearing rouge, it might need a good wash.

  • allanallan Posts: 61,446Questions: 1Answers: 10,054 Site admin

    Oh dear. Now imagine what my code looks like ;).

This discussion has been closed.