Sorting problem after setting sType

Sorting problem after setting sType

cubenzcubenz Posts: 3Questions: 0Answers: 0
edited July 2011 in General
Hi,

I have two columns, sales (number of sales) and sales value ($ value of sales, no currency symbol). Both columns will contain blanks for products with no sales.

Leaving sorting as defaults, the sales value column sorts alphabetically (99.99 > 124.00), but setting the column's sType to "numeric" partially turns off sorting altogether:

If I click on the Sales Value column, the sort image changes from asc to desc and back again OK, but the data does not sort.
If I then click on the Sales column, which has no sType, then the sort occurs.
If I now go back and click on Sales Value, I no get a correct sort (with 124.00 > 99.99).

Is there any way I can get the sort on the sales value to work first time?

Note that this is single column sorting, not multi-column.

Thanks

Quentin

Replies

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin
    If DataTables isn't detecting the column type as numeric automatically, then there must be some non-numeric data in the column somewhere. Anything which is not "[0-9]\.\-" will cause it to not match. It might be worth looking through your column to see if there is non-numeric data in it.

    It is possible that blank values are treated as strings thinking about it (can't remember off the top of my head). You could try using "-" rather than empty values and see if it is then picked up as a numeric column. If so, then a small change or a plug-in sorting function will be needed.

    Allan
This discussion has been closed.