jQuery TableSorter Custom Currency Parser [duplicate]
Possible Duplicate:
jQuery tablesorter - Not sorting column with formatted currency value
This http://tablesorter.com/docs/example-meta-parsers.html is definitely awesome for me.
However, I am italian, so I want to display my currency value like this:
€ 12.345,67
instead of this
$ 12345.67
I read something about custom parsers, but I don't know exactly how to proceed.
Can you help me?
Change the header with the currency column to
<th class="{sorter: 'commaDigit'}">Cost</th>
And add the following custom parser :
jQuery.tablesorter.addParser({
id: "commaDigit",
is: function(s) {
return /^[0-9]?[0-9,\.]*$/.test(s);
},
format: function(s) {
return $.tablesorter.formatFloat(s.replace(/,/g, ''));
},
type: "numeric"
});
精彩评论