javascript - 表格排序器过滤器和切换隐藏行不能一起工作
问题描述
我有 tablesorter 版本,它具有与这些选项完美配合的过滤器选项
$('.tablesorter').tablesorter({
theme: 'blue',
widthFixed: true,
sortList: [[5,1]],
widgets: ['zebra', 'stickyHeaders', 'filter'],
widgetOptions : {
filter_formatter : {
1 : function($cell, indx) {
return $.tablesorter.filterFormatter.select2( $cell, indx, {
match : false // exact match only
});
},
2 : function($cell, indx) {
return $.tablesorter.filterFormatter.select2( $cell, indx, {
match : true, // adds "filter-match" to header
cellText : 'Match: ', // Cell text
width: '85%', // adjusted width to allow for cell text
value: ['Lassosum','P&T','P&G'] // initial values
});
}
},
// option added in v2.16.0
}
});
所以我想最初隐藏几行,然后用复选框显示它们我有
$options.on('change', function() {
var $elementsToToggle = $('.' + this.value);
if (this.checked) {
$elementsToToggle.show();
console.log("its checked");
$("tablesorter").trigger("updateAll");
} else {
console.log("its checked");
$elementsToToggle.each(function() {
var hide = true,
elementToToggle = this;
$options.each(function() {
var optionClass = this.value,
optionValue = this.checked;
if (elementToToggle.classList.contains(optionClass) && optionValue)
hide = false;
});
if (hide === true)
$(elementToToggle).hide();
});
}
});
因此,每当我添加行时,我也在更新 tablesorter 表,但列过滤器只过滤初始行而不是动态添加的行。
解决方案
推荐阅读
- highcharts - Highcharts - 径向(或圆形)条形图 - 圆角/边框半径?
- python - 有没有一种方法可以将图像的像素值转换为 4D 数组(包括 1 个通道)而不是 Keras 的 3D 数组?
- spring-boot - SpringBootTest 上下文未加载?
- python - 为什么我的模型在 Google Colab 上训练时总是在 Keras Tensorflow 中返回 0 val loss?
- python - 刮掉搜索栏的价格 - 站点链接已更改
- python - 函数未通过所有行执行
- javascript - Yeoman 通过带有 args 的代码调用生成器
- python - 获取数据子集中(联合)最高的列名列表
- javascript - 多个套接字接收相同的随机生成的单词 - Node.js/Socket.io/Express.js
- machine-learning - 为什么higher需要深度复制基础模型的参数来创建功能模型?