【发布时间】:2014-07-09 21:09:54
【问题描述】:
我正在使用 jquery 表格排序插件。
表列是根据sql查询生成的。
如何根据属性值进行排序(升序和降序)。
注意:我不喜欢下面的代码,因为表格列是生成多个(有时是 50 列),所以我需要根据相同的属性名称对所有列进行排序。
$.tablesorter.addParser({
// set a unique id
id: 'myParser',
is: function(s) {
// return false so this parser is not auto detected
return false;
},
format: function(s, table, cell, cellIndex) {
// get data attributes from $(cell).attr('data-something');
// check specific column using cellIndex
return $(cell).attr('data-something');
},
// set type, either numeric or text
type: 'text'
});
【问题讨论】:
标签: jquery html tablesorter