The following should work:
Ext.create('Ext.grid.Panel', { title: 'Simpsons', id: 'simpsons', store: Ext.data.StoreManager.lookup('simpsonsStore'), columns: [ { text: 'Name', dataIndex: 'name' }, { text: 'Email', dataIndex: 'email', flex: 1 }, { text: 'Phone', dataIndex: 'phone' } ], height: 200, width: 400, renderTo: Ext.getBody(), dockedItems:[{ xtype:'button', handler: function() { if(Ext.getCmp('simpsons').columns[0].isVisible()) Ext.getCmp('simpsons').columns[0].setVisible(false); else Ext.getCmp('simpsons').columns[0].setVisible(true); } }] });
source share