2015-02-11 77 views
1

我正在使用tablesorter下拉菜單,使用它我可以從中選擇一個元素。我想要能夠選擇多個元素。有沒有辦法使用桌面分揀機來做到這一點?tablesort多選下拉列表

我試過查找here但我不確定它是否說有任何直接的方式來做到這一點。這個issue似乎暗示沒有直接的方法?

編輯:

代碼

 filter_functions : { 
      0 : { 
       "a" : function(e, n, f, i, $r) { return e===f; }, 
       "b" : function(e, n, f, i, $r) { return e===f; }, 
       "c" : function(e, n, f, i, $r) { return e===f; }, 
       "d" : function(e, n, f, i, $r) { return e===f; } 

      } 

回答

1

您可以使用filter_formatter選項與extra filter-formatter select2 code一起使用select2插件。 Here is a demo

filter_formatter : { 
    // default settings on first column 
    0 : function($cell, indx){ 
    return $.tablesorter.filterFormatter.select2($cell, indx, { 
     // *** select2 filter formatter options *** 
     cellText : '', // Text (wrapped in a label element) 
     match : true, // adds "filter-match" to header & modifies search 
     value : [], // initial select2 values 

     // *** ANY select2 options can be included below *** 
     // (showing default settings for this formatter code) 
     multiple : true, // allow multiple selections 
     width : '100%' // reduce this width if you add cellText 
    }); 
    } 
} 

注意:請注意,$.tablesorter.filterFormatter.select2功能尚不支持選擇2 V4.0.0測試工作。使用repsitory附帶的select2 v3.4.6。

+0

感謝您的回覆。我還不完全熟悉file_formater。我已經更新了我的代碼中第0列的代碼filter_function。有沒有辦法修改它?不過,我試圖修改你的建議。 – Trancey 2015-02-13 02:30:08

+0

我能夠像現在一樣,除了我無法刪除標記按鈕。添加的標籤上沒有關閉符號。我的意思是,如果我點擊左邊,但關閉的符號「x」沒有被顯示,它會關閉。對此有何想法? – Trancey 2015-02-13 04:05:48

+0

也許你錯過了[select2 css&images](http://cdnjs.com/libraries/select2) - 請確保它是v3.4.6。 – Mottie 2015-02-13 17:04:08