2015-09-28 64 views
3

我想添加一個搜索過濾器到tablesorter,但唯一的小部件,我可以找到添加搜索所有列和每個單獨的列的搜索輸入。我只希望搜索所有列處於活動狀態,並禁用在單個列中搜索的功能。tablesorter小部件篩選任何匹配項。如何只搜索所有列(刪除個別列的搜索)

這是JS`$(函數(){

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

每一列中搜索輸入是什麼我想移除。

感謝您的幫助

回答

1

在上面的代碼,正在啓用列篩選:

// include column filters 
filter_columnFilters: true, 

將該選項設置爲false和過濾器行將不會創建(見filter_columnFilter option)。

+0

謝謝。我非常驚訝,我錯過了。猜猜我昨晚盯着它太久了。 – Rob

1

,我在這裏看到的最簡單的方法是添加CSS線隱藏在每一列的搜索輸入。

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