Sorting mixed data types in same column

Sorting mixed data types in same column

jpeter82jpeter82 Posts: 4Questions: 0Answers: 0
edited April 2014 in General
Hi,

I have a column in my table that basically shows numeric info (floating numbers). This column comes from a mysql database. But sometimes there is no available data in the database, therefore I show Pending or Waiting strings to the user (as the data will be imported later). When I sort the column, i get the following result: -1.11; -3.54; -13.45; 1.45; 4.54; 6.12; Pending; Pending. So negative values are also sorted in alphabetical order. I tried using aoColumns, setting the column type to numeric, but that didn't do the job.

Could you please help me what else I could try?

Thanks,
Peter

Replies

  • allanallan Posts: 63,530Questions: 1Answers: 10,474 Site admin
    You can't force non-numeric data to be numeric :-). If you want to sort such data, you will need to create a little sorting plug-in which does the sort you want. There are examples and documentation here:

    http://datatables.net/development/sorting
    http://datatables.net/plug-ins/sorting

    Allan
This discussion has been closed.