View Full Version : Locking Grid column menu

27 Nov 2012, 7:00 AM
Is there a way to programmatically execute any of the items on the drop down menu for a column in a locking grid. I would like to lock and unlock or hide and unhide several columns based on a button in a tool bar on a locking grid. I am using ExtJS 4.0.7.

27 Nov 2012, 7:06 AM
You could try something like: grid.column[1].hide() (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.grid.column.Column-method-hide) and grid.column[1].show() (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.grid.column.Column-method-show)

27 Nov 2012, 7:30 AM
I tried that early on, but that does not work. With locking grids, it's like there are two grids in the DOM. One is called lockedGrid and one normalGrid. Each has a view and columns. I tried using hide, show and setVisible(false) on these columns, but it does not function. I noticed that when you use the column menu it works fine, so that's why I wondered if I could access the menu and run those options from with in my Javascript.

27 Nov 2012, 2:05 PM
There are two grids.

But you can hide any column just by grabbing it using ComponentQuery.

And you can lock/unlock by using the lock/unlock method of the locking grid passing the column.

28 Nov 2012, 8:01 AM
If you have a grid, with nested columns, and it has locked columns, creating this scenario, when trying to hide/show columns, is it best to hide/show each of the sub columns or just the master column?

28 Nov 2012, 8:12 AM
Sorry, I thought I had tried that and it had not worked, but I tried it again and it works fine. I did:
where date5Column is the itemId for the column.

Locking and unlocking the the manual for 4.0.7, where I looked, appeared to be a private function and I wasn't sure if I should be using that.

Thanks for your help.

29 Nov 2012, 2:00 AM
They are private, but they should be pretty stable. They are used by the lock and unlock menu items added when the grid is lockable. I can't see those methods ever going away.