1

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";
                }
            }
4

1 回答 1

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/

于 2013-05-29T21:56:59.100 回答