PDA

View Full Version : How to hide a column of a gridPanel?



marxan
28 Jun 2012, 6:12 AM
Hello,

I would like to hide a column from a grid when I select a value in a combo box.

I don't find anything to do such a thing in the Grid.Panel class.

I can get my grid component like this :
Ext.getCmp('gridId') but I don't know what to do with it as no method is developed to do that.

Any help will be greatly appreciated.

Regards,

friend
28 Jun 2012, 6:57 AM
This functionality is already built into grids for you. Visit the drop-down menu in the header of any column of the grid and see the 'Columns' menu option.

If you're dead set on rolling your own solution, you can do things like this:



someGrid.columns[<index>].hide();
someGrid.columns[<index>].show();

marxan
29 Jun 2012, 12:03 AM
I've looked for the Class to use to get these info, but there's something I don't catch.

Does it exist a method in the grid class that can retrieve the selected value?

Thanks

sword-it
29 Jun 2012, 2:51 AM
Hi marxan,
You can use the following code to get the selected value:



var selectedRecord = yourGrid.getSelectionModel.getSelected();


Now you can easily found the value of column you want using :
selectedRecord.data.columnName