View Full Version : Remove column from grid header context menu if hidden

3 Apr 2012, 3:38 AM
Hello all,

I am working with some hidden columns in my Grid:
column.setHidden(true) and I don't want them to be available to be chosen in the Grid column header menu where you can select which ones to display/hide. Is there a way to do this ?

I believe the decision which ones to be displayed is done in the GridView method
protected Menu createContextMenu(final int colIndex) or am I wrong? Could anyone suggest how to override this method maybe to obtain the result I am looking for?

I have attached a picture to better explain what I mean: so, the hidden ones should not appear in the highlighted menu.

Thanks in advance,


Colin Alworth
4 Apr 2012, 7:59 PM
Hiding a column by unchecking it in that menu invokes .setHidden(true) on that column config, so that you can make the same changes (hiding and showing columns that are possible to display) from in code as from the UI.

If you don't want a column shown at all, or even a possible part of the grid, remove it from the ColumnModel. Making a change like this after the grid has been rendered requires notifying the grid that a major change has been made, see GridView.refresh for more information.

8 Aug 2012, 12:13 AM
Can be achieved by setting the columnHeader of the columnconfig object to be hidden to either null or empty string "".

17 Jul 2013, 5:01 AM
Does anyone know how to do this? If a column is hidden programmatically, how can you remove it or disable it in the column header menu?

17 Jul 2013, 9:45 AM
menucreate: function(header, menu){
var columnMenuItem = menu.getComponent('columnItem');


// Find the corresponding column.
var column = Ext.getCmp(menuItem.headerId);

// Hide or disable the menuItem based on the visiblity of the column.
menuItem.setVisible( column.isVisible() );
scope: this

21 Feb 2014, 11:56 AM
To have a hidden, and unshowable column use.

hidden: true,
hideable: false

The hidden config hides it, the hideable config says whether to add it to the show/hide menu that the user sees.So that column will then be under programmatic control only to show or hide it, not user control.