我正在使用 jQuery tablesorter 插件 ( http://mottie.github.io/tablesorter/docs/index.html )
表排序器正在工作,我可以使用此代码禁用列上的排序和过滤。
// Disable sorting and filtering on 1st column
$("table thead th:eq(0)").data("sorter", false).data("filter", false);
如何使用 .data 方法来完成与此等效的操作?
$("table").tablesorter({
// sort on the 4th column, order asc
sortList: [[3,0]]
});
我的问题是我无法确定如何使用 sortList: [[3,0]] 和 .data 语法。如有任何建议,我们将不胜感激。
最佳答案
好吧,您可以使用这样的数据函数来更新保存的排序,但随后您需要实际触发排序来应用它:
$("table").data('tablesorter').sortList = [[3,0]];
$("table").trigger('update'); // apply the new sort
但实际上,我认为最好的选择是触发 sorton
事件:
$("table").trigger("sorton", [[3,0]]);
关于tablesorter - jQuery Tablesorter 和 sortList,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18258123/