这个可能有点专业,但无论如何:
引用页面:http://greg-j.com/icvm/anticartel/search-results.html
如果您查看“总罚款”的最后两列,您将看到货币输出包括 $x.xxx 十亿美元和 $x.xxx 百万美元。内置货币解析器不考虑这种格式。幸运的是,该插件允许您编写 your own parser 。但是,我没有取得任何进展。
最佳答案
看看这是否有效,我还没有测试过:
$.tablesorter.addParser({
id: 'monetary',
'is': function(s) {
return false;
},
format: function(s) {
var i = s.split('$').join('');
var suffixes = [
{name:'thousand', mult: 1000},
{name:'million', mult: 1000000},
{name:'billion', mult: 1000000000},
{name:'trillion', mult: 1000000000000}
];
for (var j in suffixes) {
if (i.indexOf(' '+suffixes[j].name) != -1) {
i = i.split(' '+suffixes[j].name).join('');
val = parseFloat(i) * suffixes[j].mult;
}
}
return val;
},
type: 'numeric'
});
$("#cartels").tablesorter({
widgets: ['zebra'],
sortList: [[0,0]],
headers: {
4: {
sorter:'monetary'
},
5: {
sorter:'monetary'
}
}
});
关于javascript - jQuery表格排序和货币发行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8088569/