mottie tablesorter,自定义过滤器在多个表上同步

时间:2013-07-24 17:37:19

标签: tablesorter

我有多个表具有完全相同的自定义过滤器。如何在我的所有表中同步过滤器,以便如果用户更改了我的一个表上的过滤器,它也会更改所有其他表上的相同过滤器?有一个简单的方法吗?

1 个答案:

答案 0 :(得分:0)

a demo上有home wiki page演示了要使用的方法。我希望这是你要求的:

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']
    });
相关问题