【问题标题】:tablesorter widget filter any match. How to only have search all columns (remove search for individual columns)tablesorter 小部件过滤任何匹配项。如何只搜索所有列(删除单个列的搜索)
【发布时间】:2015-09-28 05:24:39
【问题描述】:

我正在尝试向 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

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

感谢您的帮助

【问题讨论】:

    标签: javascript jquery tablesorter


    【解决方案1】:

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

    // include column filters
    filter_columnFilters: true,
    

    将此选项设置为false,将不会创建筛选行(请参阅filter_columnFilter option)。

    【讨论】:

    • 谢谢。我非常惊讶我错过了。我猜我昨晚盯着它太久了。
    【解决方案2】:

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

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

    【讨论】:

      猜你喜欢
      • 2019-04-10
      • 2021-08-14
      • 2023-01-07
      • 1970-01-01
      • 2014-07-04
      • 1970-01-01
      • 1970-01-01
      • 2010-10-05
      • 1970-01-01
      相关资源
      最近更新 更多