开发者

jQuery TableSorter Custom Currency Parser [duplicate]

开发者 https://www.devze.com 2023-04-03 13:43 出处:网络
This question already has answers 开发者_C百科here: Closed 10 years ago. Possible Duplicate: jQuery tablesorter - Not sorting column with formatted currency value
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

精彩评论

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

关注公众号