【发布时间】:2015-04-29 17:11:01
【问题描述】:
我正在为 jquery 使用 tablesorter 并使用此页面作为示例
http://mottie.github.io/tablesorter/docs/example-parsers.html
并使用此插件:
http://mottie.github.io/tablesorter/js/jquery.tablesorter.js
这是对“状态”进行排序的代码
$.tablesorter.addParser({
id: 'status',
is: function(s) {
// return false so this parser is not auto detected
return false;
},
format: function(s, table, cell, cellIndex) {
// format your data for normalization
//console.log(cellIndex);
return s.toLowerCase()
.replace(/Deleted/,4)
.replace(/Finished/,3)
.replace(/Cancelled/,2)
.replace(/In Progress/,1)
.replace(/New/,0);
},
// set type, either numeric or text
type: 'numeric'
});
$('#request').tablesorter(
{
debug:false,
widthFixed: false,
headers: {
0: { sorter: false },
3: { sorter: false },
4: { sorter: 'dates-desired' },
6: { sorter: 'dates-projected' },
7: { sorter: 'status' },
8: { sorter: false },
}
}
);
但是当我点击状态标题时,什么也没有发生
当我进行调试选项时:true,这是 o/p:
“在 7,0 和 dir 0 时间(1ms)上排序”jquery.tablesorter.min.js:157:5
"重建表 (4ms)" jquery.tablesorter.min.js:157:5 "完成
应用 0 个小部件 (0ms)"
任何帮助表示赞赏。
【问题讨论】:
-
请格式化您的代码。
标签: jquery tablesorter