Custom data type

Custom data type

mole1066mole1066 Posts: 7Questions: 0Answers: 0
edited September 2010 in General
I'm assuming this should be able to be done with type detection, but can't work it out from the documentation.

I have a column that has a priority that can be High, Medium, or Low. I therefore want to define a custom data type to sort in the correct manner.

has anyone done and this? any example code on how to do this?

Michael

Replies

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Yes indeed this can be done with type detection. Basically what you need to do is have a sorting plug-in ( http://datatables.net/development/sorting - http://datatables.net/plug-ins/sorting ) which will take the strings you want and (probably the easiest method) convert them to numbers which can then be sorted numerically (like many of the example). So for example assign a value of 1 to "High", 2 to "Medium" etc.

    Allan
  • mole1066mole1066 Posts: 7Questions: 0Answers: 0
    OK that makes sense. Could you give an example of how that would be done. Having looked through the examples I can't see a method that readily lends itself to this, or cant work out the syntax

    Michael
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    Hi Michael,

    Sorry for the delay! I've put up an example of how it might work on the sorting plug-ins page: http://datatables.net/plug-ins/sorting#Priority . It should be fairly easy to change the words or the order if you want.

    Regards,
    Allan
This discussion has been closed.