I am using the DataTables jQuery plugin. I am trying to enable sort interaction, but when sorting it sorts alphabetically and not numerically. As you can see in the enclosed picture, -4317.93
is shown after -631
and -456
. How can I make DataTable
sort a column numerically?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- How to fix IE ClearType + jQuery opacity problem i
- void before promise syntax
- jQuery add and remove delay
Updated answer
With the latest version of DataTables you need to set the
type
property of the object you provide in thecolumnDefs
array, like this:Note that there are many other methods of sorting which can be found in the documentation
Original answer
You need to add the
sType
parameter to your column definition.For example:
More information in the DataTable documentation: http://www.datatables.net/plug-ins/sorting