2012-12-04 18 views
2

我有代碼:jQuery的數據表 - 可見列

$('#table').dataTable({ 
     "aoColumnDefs": [ 
       { "bVisible": true, "aTargets":[0], "mDataProp":"name" }, 
       { "bVisible": true, "aTargets":[1], "mDataProp":"surname" }, 
       { "bVisible": true, "aTargets":[2], "mDataProp":"number" } 
     ] 
    }); 

此代碼顯示,當我有可變Search設置,但是當我有Search設置我想只顯示姓氏和列數, 我怎樣才能做到這一點?

+0

我不明白,你是什麼意思? – faszynski

+0

如果搜索爲false,您是否可以運行單獨的函數來隱藏列? – CR41G14

+0

不,因爲我沒有單獨的功能,因爲我不想重複相同的代碼 – faszynski

回答

3

嘗試

var Search = false; 

$('#table').dataTable({ 
     "aoColumnDefs": [ 
       { "bVisible": function() { return Search; }, "aTargets":[0], "mDataProp":"name" }, 
       { "bVisible": true, "aTargets":[1], "mDataProp":"surname" }, 
       { "bVisible": true, "aTargets":[2], "mDataProp":"number" } 
     ] 
    });