Using Datatables when numbers are enclosed in parenthesis

Using Datatables when numbers are enclosed in parenthesis

Adam84Adam84 Posts: 10Questions: 4Answers: 0

Hi all,

I am new to Datatables and I'm trying to work out how to use the sort functionality when numbers are enclosed in parenthesis.
As you can see from the last column in my example http://jsfiddle.net/Adam84/q4xawevz/1/ the last column does not display in the correct order when sorted.

I believe the numbers that are enclosed are being read as a string and are therefore being displayed alphanumerically. How do I go about getting them to display numerically instead?

I have tried setting the sType to 'numeric' but to no avail. Any advice or examples would be greatly appreciated.

Thanks,
Adam

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    edited January 2015

    I believe the numbers that are enclosed are being read as a string and are therefore being displayed alphanumerically.

    Spot on! What you would need is a sorting plug-in that will remove the brackets and then sort the numbers numerically. This plug-in would do the trick.

    Allan

  • Adam84Adam84 Posts: 10Questions: 4Answers: 0

    Hi Allan,

    Thanks for the quick response. Can you re-post that plug-in link. It doesn't seem to go anywhere.

    Thanks again,

    Adam

  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Answer ✓

    Oops - sorry. Fixed it above.

    Allan

This discussion has been closed.