PDA

View Full Version : Not hidable columns in GXT Grids



windjunkie
27 Mar 2014, 6:08 AM
I am looking for a method to prevent a user from hiding certain columns in my grids. I was trying to override Menu createContextMenu(final int colIndex) method of GridView where I find the submenu items that are related to my not-hidable columns and call disable() on them:



...
for (Component menuItem : menu.getItems()) {
String text = ((MenuItem) menuItem).getText();
if (((MenuItem) menuItem).getSubMenu() != null && (text.equals("Columns"))) {
for (Component subMenuItem : ((MenuItem) menuItem).getSubMenu().getItems()) {
String subMenuItemText = ((MenuItem) subMenuItem).getText();
if (<i want this column to be not hidable>) {
subMenuItem.disable();
}
}
}
}
...


It almost works - when the grid is just rendered the menu items that I disabled are greyed out and they don't accept user's input. However it all breaks after some other, not disabled columns are toggled. All of a sudden the disabled sub-menu items become enabled.

I am using GXT 2.2.6.

Thank you!

windjunkie
27 Mar 2014, 12:49 PM
The reason of the problem is found. Any change in columns call GXT listeners and eventually restrictMenu method of GridView is called. This overrides all my disable settings. The solution is to add custom listener let GXT' listener do its job and then overwrite the enable/disable settings.