I have a problem and I need help.
For example, I need to get the CheckBox object that is on MenuItem on the Grid Header.
On the grid header has a menu with 3 options: Sort Ascending, Sort Descending and Columns.
Choosing columns, open other menu with the CheckBox for each column where we can hiden or show the column in the grid. I need to get this CheckBox object or MenuItem object to add event on it.
In the class com.extjs.gxt.ui.client.widget.grid.GridView.class I put a break point at line 803. I need to get the CheckMenuItem object to add a new event with addListener();
The GridView code is:
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);
}
MenuItem columns = new MenuItem();
columns.setText(GXT.MESSAGES.gridView_columnsText());
columns.setIcon(getImages().getColumns());
columns.setData("gxt-columns", "true");
final Menu columnMenu = new Menu();
int cols = cm.getColumnCount();
for (int i = 0; i < cols; i++) {
if (shouldNotCount(i, false)) {
continue;
}
final int fcol = i; 797 final CheckMenuItem check = new CheckMenuItem(); //I need to get this object CheckMenuItem
check.setHideOnClick(false);
check.setText(cm.getColumnHeader(i));
check.setChecked(!cm.isHidden(i));
check.addSelectionListener(new SelectionListener<MenuEvent>() {
public void componentSelected(MenuEvent ce) { 803 cm.setHidden(fcol, !cm.isHidden(fcol)); //Break point here
804 restrictMenu(columnMenu);
}
});
columnMenu.add(check);
}
I've tried all forms and no result:
Grid grid = getGrid();
grid.getView().getHeader().getContextMenu();
grid.getView().getHeader().getContextMenu().getParentItem();
grid.getView().getHeader().getContainer().getContextMenu().getContextMenu().getWidget(1);
grid.getView().getHeader().getContainer().getContextMenu();
No, I can do this, to verify if a column is hidden or not and change, but what I really need to know is how can I add a event writen by me. So when that native event is run, my event is run too without override the native event.