Integers are sorted by first integer, not the entire integer value?

Integers are sorted by first integer, not the entire integer value?

NJWebDesignNJWebDesign Posts: 7Questions: 3Answers: 0

Upon initial load, my table is displaying, I assume, in order of the primary key value however they are being displayed as follows:

1
2
27
29
3
31
4...

It's only ordering using the first integer, not the entire integer value. Is this a bug?
NJ

Answers

  • NJWebDesignNJWebDesign Posts: 7Questions: 3Answers: 0

    I've tried recreating this here:
    http://live.datatables.net/tapadego/1/edit

    ...but of course the above works, yet my table is set up exactly the same way albeit my values are dynamic.

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    Hi @NJWebDesign ,

    When the table loads, the code tries to determine the data type. If it's sorting like that, it thinks the column is a string, so maybe there's a value in there that's non-numeric. You can force the type by setting columns.type to num,

    Cheers,

    Colin

  • NJWebDesignNJWebDesign Posts: 7Questions: 3Answers: 0

    Ah, yes, there's a NULL value for some records.
    Where do I edit the columns.type option? Thank you.

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    Either in the columnDefs, or columns.

    C

  • NJWebDesignNJWebDesign Posts: 7Questions: 3Answers: 0

    Ah. That'll be me hitting a brick wall then!
    Where/how do you change these options? Are they values in a JS file that need changed?

    Sorry, I am completely new to stuff like this.
    NJ

  • colincolin Posts: 15,112Questions: 1Answers: 2,583

    It's when you initialise the table. This example here is setting visibility, and you can see the declarations there.

This discussion has been closed.