开发者

jQuery TableSorter Custom Currency Parser [duplicate]

This question already has answers 开发者_C百科here: Closed 10 years ago.

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"
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜