ExtJs4 - What is the equivalent to the grid Column

2020-03-12 07:37发布

What is the equivalent to the ExtJs3 Ext.grid.ColumnModel in ExtJs4?

What I want to do is hide a column, I did something like below in ExtJs3:

grid.colModel.setHidden(1, true);

4条回答
一纸荒年 Trace。
2楼-- · 2020-03-12 07:56

Another solution more flexible :

grid.down("[dataIndex="+di+"]").setVisible(v);

You can change dataIndex for another property like name or whatever.

查看更多
相关推荐>>
3楼-- · 2020-03-12 08:09

You can hide/show column using setVisible method of Ext.grid.column.Column:

grid.columns[1].setVisible(false);
查看更多
Juvenile、少年°
4楼-- · 2020-03-12 08:14

Ext.grid.header.Container

code of Ext.panel.Table:

 headerCtCfg = me.columns || me.colModel, 
 ...
if (headerCtCfg instanceof Ext.grid.header.Container) {
            me.headerCt = headerCtCfg;
            me.headerCt.border = border;
            me.columns = me.headerCt.items.items;
}

so u can use

grid.columns[i].hide()/show()
查看更多
男人必须洒脱
5楼-- · 2020-03-12 08:18

The other answers can be problematic if your column indexes change.

Here is another solution:

Set itemId on the column definition:

{
        itemId: 'myActionColumn',
        xtype: 'actioncolumn',
        width: 50,
        items: [ ...
}

Then to hide:

grid.down('#myActionColumn').hide();
查看更多
登录 后发表回答