ExtJs 4: How do I hide/show grid columns on the fly?

Viewed 32483

I need to show/hide columns of a grid on the fly, but it seems that ExtJs 4 has no implemented method for that.

In previous versions I should use columnModel, what doesn't exist anymore.

Just get grid.columns[index] and hide() or show() doesn't affect the grid.

Use grid.columnManaget.getColumns()[index].hide() can really hide the column, but it cannot be shown again (as getColumns() does not return that column after that).

4 Answers
Ext.getCmp('gridId').columnManager.getColumns()[index].hide();
Ext.getCmp('gridId').doLayout();

This works for me

Related