ExtJs4 - What is the equivalent to the grid ColumnModel?
Asked Answered
M

4

9

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);
Mertz answered 18/5, 2011 at 8:54 Comment(0)
R
16

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

grid.columns[1].setVisible(false);
Rosiorosita answered 18/5, 2011 at 11:0 Comment(0)
B
3

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();
Baun answered 14/9, 2012 at 14:12 Comment(1)
Great idea, IMO much cleaner than the accepted answer,Gwendolin
J
2

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()
Joub answered 20/5, 2011 at 15:42 Comment(0)
I
0

Another solution more flexible :

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

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

Impregnate answered 17/4, 2015 at 14:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.