I’m messing with a sortable table in mootools, where you can click on the th and sort the values in the table.
However, it seems to be treating the integer values as text. How do I declare the table column data type so as to avoid this issue?
Here’s a fiddle to demonstrate: http://jsfiddle.net/mBmc3/1/
If you click on the “values” header, you’ll see that the column is sorted like a string.
When you create the table object, you must specify which parser to use when sorting the data:
That line at the end of the option object:
…maps each column to a specific parser. The parser is used to format each column’s data into the type that it should be sorted as. Each column is treated as a string otherwise.
jsFiddle: http://jsfiddle.net/d3DLG/
Documentation
HtmlTable.Sort– http://mootools.net/docs/more/Interface/HtmlTable.Sort