Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ExtJs4 - What is the equivalent to the grid ColumnModel?

Tags:

grid

extjs

extjs4

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);
like image 706
shane87 Avatar asked May 18 '11 08:05

shane87


3 Answers

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

grid.columns[1].setVisible(false);
like image 164
ischenkodv Avatar answered Oct 19 '22 16:10

ischenkodv


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();
like image 28
John Helfert Avatar answered Oct 19 '22 14:10

John Helfert


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()
like image 33
atian25 Avatar answered Oct 19 '22 16:10

atian25