Custom Numerical Sorting

Custom Numerical Sorting

mylokmylok Posts: 8Questions: 0Answers: 0
edited January 2010 in General
I have one Column html format like this:
[code]
10[/code]
It work fine but style sheet(width) doesnot apply to td.

If I change to this:
[code]10 [/code]
I can set up the width but broke sorting function.

Anyone know how can I make sorting function work when sorting element have wrapper?(like span, div.. etc)
Thanks.

Replies

  • allanallan Posts: 63,695Questions: 1Answers: 10,500 Site admin
    Hi mylok,

    This was brought up earlier today: http://datatables.net/forums/comments.php?DiscussionID=312&page=1#Item_4 . You can use the plug-in here: http://datatables.net/plug-ins/sorting#numbers_html . Odd that the width isn't used from the style though... If you put it into the TH element, does it then work?

    Regards,
    Allan
  • mylokmylok Posts: 8Questions: 0Answers: 0
    Hi allan, thank for reply.
    I try put width in TH, no work, but the background-color work, Here is page render Html
    [code]Ln[/code]

    Also, can you show me how to use that sorting plug-in?
    I simple copy them inside document.ready() function, it is not work, then I try put them before document.ready() it is not work, then put them in external file and refer file after the jquery file, it is still not work...
    I am stuck now... :(
  • allanallan Posts: 63,695Questions: 1Answers: 10,500 Site admin
    Hi mylok,

    Here is how you can use the sorting plug-in: http://datatables.net/examples/api/sorting_plugin.html . Note you'll need to specify the 'sType' for the column to be 'num-html', rather than using the automatic type detection (there isn't automatic type detection for this sorting type).

    Regarding the width: I think there are two options at the moment then (and I'll look into why this might not be working), firstly you can set bAutoWidth:false in the initialisation object, and you can set sWidth:40px in the columns initialisation part.

    Regards,
    Allan
  • mylokmylok Posts: 8Questions: 0Answers: 0
    Thank very much!
This discussion has been closed.