2013-03-22 55 views
2

我得到這個代碼http://mottie.github.com/tablesorter/docs/example-options-headers.html的jQuery的tablesorter - 禁用排序和過濾

// BONUS TIP: disable a column using jQuery data directly 
// but do it before the table initializes 
$("table thead th:eq(5)").data("sorter", false); 

這工作,我可以添加2號線,如下圖所示,以禁用過濾。但是,我想將它們合併爲一行。我會怎麼做?

// I Want to combine this into the prev line 
$("table thead th:eq(5)").data("filter", false); 
+0

除了禁用排序和過濾器並將它們組合成一條線,這將是很好也看到了如何禁用多列。例如,在一行代碼中禁用第5列和第7列中的排序和過濾。 – 12AX7 2013-03-22 22:12:54

回答

3

沒有經過測試的但嘗試這個

$("table thead th:eq(5), table thead th:eq(7)").data("sorter", false).data("filter", false); 
+0

這很好!謝謝。 – 12AX7 2013-03-23 18:39:57

+0

@ 12AX7:歡迎您... :) – 2013-03-24 14:19:44

2

我想補充一點,你可以結合jQuery的data功能:

$("table thead th:eq(5), table thead th:eq(7)").data({ 
    sorter: false, 
    filter: false 
}); 
0

要爲表格單元格禁用排序添加類你的頭

class="sorter-false" 

也可以在添加參數 「的tablesorter」 初始化:

headers : { 0 : { sorter: false } } 

禁用過濾器在初始化添加參數

headers: { 0: { filter: false} } 

DOM(標題)元素狀陣列從0

開始

$(".someclass").tablesorter({ 
     widgets : [ "filter" ], 
     headers: { 0: {filter: false}, 
        1: {sorter: false, filter: false}, 
        2: {sorter: false} 
     } 
    });