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

2 comments:

  1. Replies
    1. :) Yeah!!... That was the only solution I found at that time. With the new releases and fixes, may be they have come up with something better, will need to check.. That's one reason you can't rely on them..things change over a period of time/releases..

      Delete