2013-05-29 70 views
1

我需要隱藏列的列索引extjs grid面板得到ExtJS的網格面板隱藏列的列索引

columnhide: function() { 
      var cell = this.getEl().query('.x-grid-cell-inner'); 

      for(var i = 0; i < cell.length; i++) { 
      if (i%2 != 0){ // Instead of this i, want to change the style to none for the hide column, so i need to get the column index of hide column in grid panel 
        cell[i].style.display= "none"; 
       } 
      } 

回答

3

使用columnhide聽衆:

columnhide: function(ct, column, eOpts) { 
    alert(column.getIndex()); 
}, 

或者,您可以遍歷網格列並檢查每列的isHidden()屬性:

Ext.each(grid.columns, function(column, index) { 
    if (column.isHidden()) { 
     alert('column at index ' + index + ' is hidden'); 
    } 
}); 

我有一個測試用例設置在這裏:http://jsfiddle.net/cCEh2/

+0

http://jsfiddle.net/vd7f8/11 ---這裏當我點擊col1/col2來隱藏,columnhide函數裏面我想獲得col1/col2的列索引在複選框取消選擇 – user2353513

+0

http://jsfiddle.net/vd7f8/12/ - 我修改了您的示例以顯示您剛剛隱藏的列的索引的警報。 –

+0

非常感謝你...我工作過...你救了我的一天:-) – user2353513