jQuery tablesorter 插件辅助“隐藏"排序 [英] jQuery tablesorter plugin secondary "hidden" sorting
问题描述
我正在使用 jQuery 表格排序器插件,并且我有一列包含这样的月份和年份名称
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的tablesorter正是我所需要的;将值存储在属性中进行排序的能力非常棒.
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屋!