获取extjs网格面板中隐藏列的列索引

时间:2013-05-29 18:20:32

标签: extjs

我需要在extjs grid面板

中获取隐藏列的列索引
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";
                }
            }

1 个答案:

答案 0 :(得分: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/

相关问题