我正在我的表分类器上使用解析器,我正在使用它来设置我的表首次显示时的顺序。问题是一旦显示我的表我想忽略解析器并使用默认排序选项允许用户对表进行排序。这可能吗?如果是这样我该怎么办?这是我的tablesorter addParer代码:$ .tablesorter.addParser({
//give an id to the parser
id: 'campaigns',
is: function(s) {
return false;
},
format: function(s) {
//remove any numbers and spaces in the string s
var state = s.replace(/[0-9]/g, '').replace(/\s/g, '');
//change inactive to a 1 and active to a 2
//only want this to apply on load otherwise after the table has loaded
//I don't want this to be used. I just want to ignore it
return state.toLowerCase().replace(/inactive/,1).replace(/active/,2);
},
//sort on a numeric type
type: 'numeric'
});
$(function() {
$("table#game-data-table").tablesorter({
//sort based off of active inactive, then off column 4,and finally off column 1
sortList: [[1,1], [3,1], [0,0]],
headers: {
1: {
sorter: 'campaigns'
}
}
});
});