【发布时间】: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;
});
});`
每列中的搜索输入是我想要删除的。
感谢您的帮助
【问题讨论】:
标签: javascript jquery tablesorter