fnSortListener usage

fnSortListener usage

DaveomaniaDaveomania Posts: 15Questions: 0Answers: 0
edited July 2010 in General
Hi there,

I am having problems trying to get my data to sort properly. For example, if I have a table with 10 rows and each row is 1-10:

1
2
3
4
5
6
7
8
9
10

When I hit the sort for the top of that row, I end up with:

1
10
2
3
4
5
6
7
8
9

When I load the table I use [code]fnSort([[0, 'asc']]);[/code] and that works for the initial rendering.

So what I am wondering is can I use the listener and attach it to only that column header? Using iDataSort gives me the same unwanted results.. so I need a way to get around this.

Thanks for any help!!!

Dave

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    The sorting order you indicate suggests that DataTables has picked they type up as 'string' rather than 'numeric'. I would guess that this is because you have white space around the numbers in the table (or some other non-numeric character). You could try 1.7 beta 5 which will automatically deal with this, or modify your HTML to not have any white space.

    Regards,
    Allan
  • DaveomaniaDaveomania Posts: 15Questions: 0Answers: 0
    Hi Allan and thanks for the response,

    I will try removing the whitespace and if that fails I will attempt using 1.7 beta 5. I will post back my outcome.

    :D
  • DaveomaniaDaveomania Posts: 15Questions: 0Answers: 0
    Well I trimmed the values coming out of the database and then there you have it. It is sorting properly.

    Thank you very much Allan!

    Dave
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Good to hear this worked :-). This is why this feature is included in the 1.7 series :-)

    Regards,
    Allan
This discussion has been closed.