Javascript 表分拣器过滤器和切换隐藏行不一起工作
我有一个tablesorter版本,它有过滤器选项,可以很好地使用这些选项Javascript 表分拣器过滤器和切换隐藏行不一起工作,javascript,filter,jquery-select2,tablesorter,Javascript,Filter,Jquery Select2,Tablesorter,我有一个tablesorter版本,它有过滤器选项,可以很好地使用这些选项 $('.tablesorter').tablesorter({ theme: 'blue', widthFixed: true, sortList: [[5,1]], widgets: ['zebra', 'stickyHeaders', 'filter'], widgetOptions : {
$('.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表,但列过滤器只过滤初始行,而不是动态添加的行