jQuery tablesorter插件次要“隐藏"排序 [英] jQuery tablesorter plugin secondary "hidden" sorting
问题描述
我正在使用jQuery tablesorter插件,并且有一个包含这样的月份和年份名称的列
I'm using the jQuery tablesorter plugin and I have a column that contains name of month and year like this
April, 1975
January, 2001
我想对该列进行排序,就好像它是日期列一样.据我了解,可以用其他隐藏"值对列进行排序,但是我似乎找不到该功能的文档.有帮助吗?
I would like to sort this column as if it were a date column. As I understand it, it is possible to sort the column with some other 'hidden' value, but I just can't seem to find the documentation for that feature. Any help out there?
更新
此叉子 http://mottie.github.com/tablesorter/docs/index.html 那个分拣员正是我所需要的;存储值以在属性中进行排序的功能非常有效.
This fork http://mottie.github.com/tablesorter/docs/index.html of the tablesorter had just what I needed; the ability to store the value to sort by in an attribute, worked really great.
推荐答案
我有 tablesorter ,使您可以编写可提取数据的解析器表单元格中的属性,并分配特定的 textExtraction每列.
I have a fork of tablesorter that allows you to write a parser that can extract data attributes from the table cell as well as assign specific textExtraction for each column.
$(function(){
$.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'
});
$('table').tablesorter({
headers : {
0 : { sorter: 'myParser' }
}
});
});
这篇关于jQuery tablesorter插件次要“隐藏"排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!