简体   繁体   中英

ExtJs4 - What is the equivalent to the grid ColumnModel?

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);

您可以使用Ext.grid.column.Column的setVisible方法隐藏/显示列:

grid.columns[1].setVisible(false);

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();

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()

Another solution more flexible :

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM