Friday, August 17, 2012

EXTJs 4 equivalent of getColumnModel()

Extjs 3 has the method grid.getColumnModel() which will return a column model and then yu can dynamically add/remove columns,etc

How do we achive this in EXTJs 4?

Every column can have an itemId. i.e while configuring the columns:
header: 'Column1',
dataIndex: 'data',
width: 100,
itemId: 'column1'

To get the column with id:column1 we need to use this: 
var column=grid.getView().getHeaderCt().child('#column1');
now we can use the returned column object like:
column.setVisible(false); //to hide the column