Sorting columns by Numeric Value containing HTML and Text
Sorting columns by Numeric Value containing HTML and Text
KyleR
Posts: 1Questions: 1Answers: 0
I have tables with data in such as:
<td><span class="label label-primary">$9.77 PKA</span></td>
<td><span class="label label-primary">$11.14 PKA</span></td>
The sorting of the columns, is ordering it by the HTML or TEXT, as $9.77 is less than $11.14 but appears first when ordered.
How can I go about achieving this?
Here is my current JS:
$("#zero-configuration").dataTable({
'iDisplayLength': 200
});
This discussion has been closed.
Answers
As there is non-numeric data (the
PKA
part) DataTables can't automatically detect this is a numeric data type - hence why it is string sorting.So there are a number of options to address this:
Allan