View Full Version : Grid Header Menu.
ikovaltaras
15 Dec 2010, 4:14 AM
Hi.
Maybe someone know how to remove in grid columns header "Columns" menu item with list of columns?
I know that this is default functionality, but i dont need this, and not fount any methods in API to do this, just disable all menu. But i need menu without Columns menu item.
You can listen to the Events.HeaderContextMenu fired by the grid, get the Menu and remove the items you want to remove there.
ikovaltaras
15 Dec 2010, 4:23 AM
thx, what is id of Columns menu item? because getting meni item by title is not good option.
The only wait to get it at the moment is by index.
ituren
15 Dec 2010, 8:40 PM
You mean you want the two sort menu menu items,and do not want the column check boxes menu?
Or you just don't want the whole menu?
I happen to have some code for the first one
public class IGridView extends GridView{
@Override
protected Menu createContextMenu(final int colIndex) {
final Menu menu = new Menu();
if (cm.isSortable(colIndex)) {
MenuItem item = new MenuItem();
item.setText(GXT.MESSAGES.gridView_sortAscText());
item.setIcon(getImages().getSortAsc());
item.addSelectionListener(new SelectionListener<MenuEvent>() {
public void componentSelected(MenuEvent ce) {
doSort(colIndex, SortDir.ASC);
}
});
menu.add(item);
item = new MenuItem();
item.setText(GXT.MESSAGES.gridView_sortDescText());
item.setIcon(getImages().getSortDesc());
item.addSelectionListener(new SelectionListener<MenuEvent>() {
public void componentSelected(MenuEvent ce) {
doSort(colIndex, SortDir.DESC);
}
});
menu.add(item);
}
return menu;
}
}
and set your grid like this
yourGrid.setView(new IGridView());
And if you don't want the whole menu.
Do like this:
List<ColumnConfig> configs = grid.getColumnModel().getColumns();
for (ColumnConfig columnConfig : configs) {
columnConfig.setMenuDisabled(true);
}
ikovaltaras
16 Dec 2010, 12:42 AM
yes I need only sorting items. Sven answer is right, i did as he recomended and it works.
Powered by vBulletin® Version 4.1.5 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.