jquery TableSorter - 如何动态关闭过滤器
jquery TableSorter - How do I turn off filters dynamically
我正在使用 TableSorter 版本 2.28.1。我打开了过滤器。
widgets: ["zebra", "filter"]
我希望能够在显示 table 之前在我的代码中关闭或打开过滤器。这基于来自上一页的参数。
我正在使用 C#,页面上的 table 是一个 .net Gridview 控件。
有人有什么想法吗?
使用applyWidgetId and removeWidget methods to toggle the filter widget (demo的组合:
HTML
<button type="button">Add Filter</button>
<table class="tablesorter">...</table>
脚本
$(function() {
var $table = $('table');
$('button').click(function(){
var btn = $(this),
addWidget = /add/i.test(btn.text());
if (addWidget) {
btn.text('Remove Filter');
$table.trigger('applyWidgetId', 'filter');
} else {
btn.text('Add Filter');
$table.trigger('removeWidget', 'filter');
}
return false;
});
$table.tablesorter({
theme: 'blue',
widgets: ['zebra']
});
});
谢谢@Mottie。 "applyWidgetId" 正是我所需要的。对我来说,这有点简单。我只需要能够在初始化时根据变量的值打开或关闭过滤器。所以这就是我所做的......
widgets: ["zebra"],
initialized: function (table) {
if ('<%= showFilter %>' == 'Y')
{
$(table).trigger('applyWidgetId', 'filter')
}
我正在使用 TableSorter 版本 2.28.1。我打开了过滤器。
widgets: ["zebra", "filter"]
我希望能够在显示 table 之前在我的代码中关闭或打开过滤器。这基于来自上一页的参数。
我正在使用 C#,页面上的 table 是一个 .net Gridview 控件。
有人有什么想法吗?
使用applyWidgetId and removeWidget methods to toggle the filter widget (demo的组合:
HTML
<button type="button">Add Filter</button>
<table class="tablesorter">...</table>
脚本
$(function() {
var $table = $('table');
$('button').click(function(){
var btn = $(this),
addWidget = /add/i.test(btn.text());
if (addWidget) {
btn.text('Remove Filter');
$table.trigger('applyWidgetId', 'filter');
} else {
btn.text('Add Filter');
$table.trigger('removeWidget', 'filter');
}
return false;
});
$table.tablesorter({
theme: 'blue',
widgets: ['zebra']
});
});
谢谢@Mottie。 "applyWidgetId" 正是我所需要的。对我来说,这有点简单。我只需要能够在初始化时根据变量的值打开或关闭过滤器。所以这就是我所做的......
widgets: ["zebra"],
initialized: function (table) {
if ('<%= showFilter %>' == 'Y')
{
$(table).trigger('applyWidgetId', 'filter')
}