How to sort on this column?

How to sort on this column?

oskarroskarr Posts: 2Questions: 0Answers: 0
edited June 2013 in General
Hi, how do I make sure Datatables use the correct price for sorting?
I want to sort on the 6.99 price. Tried with a mData function with no luck.

[code]
£6.99
€8.18
[/code]

[code]$('#table').dataTable({
"aoColumns": [
{ "mData": function ( source, type, val ) {
// what do to here? i dont want to change the display, only the value datatable is sorting on
return source;
}}
]
});
[/code]

Replies

  • allanallan Posts: 63,516Questions: 1Answers: 10,472 Site admin
    mData isn't going to help in this case, you'll need to write a sorting plug-in that extracts the numeric data that you want to sort on: http://datatables.net/development/sorting#type_based .

    There are a number of sorting plug-ins already valuable here which you might be able to use as a template: http://datatables.net/plug-ins/sorting

    Allan
  • oskarroskarr Posts: 2Questions: 0Answers: 0
    Thank you. There is a plugin for extracting the numbers, I see. So now all I need to a way of selecting which one of the two numeric values to choose?

    Is there a way to select the innerHTML of a specific domElement and pass it to the sorting plug-in? Like my [code]$10[/code] example.
This discussion has been closed.