tablesorter小部件过滤任何匹配。如何仅搜索所有列(删除对各列的搜索)

时间:2015-09-28 05:24:40

标签: javascript jquery tablesorter

我正在尝试向tablesorter添加搜索过滤器,但我能找到的唯一小部件会添加搜索所有列以及每个列的搜索输入。我只希望搜索所有活动列,并禁用在各个列中搜索的功能。

这是JS` $(function(){

var $table = $('table').tablesorter({
    theme: 'blue',
    widgets: ["zebra", "filter"],
    widgetOptions : {
        // filter_anyMatch replaced! Instead use the filter_external option
        // Set to use a jQuery selector (or jQuery object) pointing to the
        // external filter (column specific or any match)
        filter_external : '.search',
        // add a default type search to the first name column
        filter_defaultFilter: { 1 : '~{query}' },
        // include column filters
        filter_columnFilters: true,
        filter_placeholder: { search : 'Search...' },
        filter_saveFilters : true,
        filter_reset: '.reset'
    }
});
// make demo search buttons work
$('button[data-column]').on('click', function(){
    var $this = $(this),
        totalColumns = $table[0].config.columns,
        col = $this.data('column'), // zero-based index or "all"
        filter = [];

    // text to add to filter
    filter[ col === 'all' ? totalColumns : col ] = $this.text();
    $table.trigger('search', [ filter ]);
    return false;
});

});`

Here is a link to the table

每列中的搜索输入是我想删除的内容。

感谢您的帮助

2 个答案:

答案 0 :(得分:1)

我在这里看到的最简单方法是添加一条css行来隐藏每列中的搜索输入。

.input.tablesorter-filter {
    display: none;
}

答案 1 :(得分:1)

在上面的代码中,正在启用列过滤器:

// include column filters
filter_columnFilters: true,

将此选项设置为false,并且不会创建过滤器行(请参阅filter_columnFilter option)。

相关问题