1

我有多个表具有完全相同的自定义过滤器。如何在我的所有表之间同步过滤器,以便如果用户更改我的一个表上的过滤器,它也会更改所有其他表上的相同过滤器?是否有捷径可寻?

4

1 回答 1

0

主页 wiki 页面上有一个演示,演示了使用的方法。我希望这是您所需要的:

var ts = $.tablesorter,
    sorting = false,
    searching = false;

$('table')
    .on('sortBegin filterEnd', function (e, filters) {
        if (!(sorting || searching)) {
            var table = this,
                c = table.config,
                filters = ts.getFilters(table),
                $sibs = c.$table.siblings('.tablesorter');
            if (!sorting) {
                sorting = true;
                $sibs.trigger('sorton', [c.sortList, function () {
                    setTimeout(function () {
                        sorting = false;
                    }, 500);
                }]);
            }
            if (!searching) {
                $sibs.each(function () {
                    ts.setFilters(this, filters, true);
                });
                setTimeout(function () {
                    searching = false;
                }, 500);
            }
        }
    })
    .tablesorter({
        theme: 'blue',
        widthFixed: true,
        widgets: ['filter']
    });
于 2013-07-25T13:09:54.340 回答