SmartClient Version: v9.1p_2014-06-04/Pro Deployment (built 2014-06-04)
I have an example below where I am overriding ListGrid.getHeaderContextMenuItems(Integer) to add a custom header context-menu item and I am not getting the expected column number from the event when I click on my custom context-menu item.
No matter what column header I click on to open the header context-menu, when I click on the "Custom Menu Item" menu item, event.getColNum() is always 1.
Thanks
I have an example below where I am overriding ListGrid.getHeaderContextMenuItems(Integer) to add a custom header context-menu item and I am not getting the expected column number from the event when I click on my custom context-menu item.
No matter what column header I click on to open the header context-menu, when I click on the "Custom Menu Item" menu item, event.getColNum() is always 1.
Code:
@Override protected MenuItem[] getHeaderContextMenuItems(Integer fieldNum) { final List<MenuItem> menuItems = new ArrayList<MenuItem>(); final MenuItem[] currentMenuItems = super.getHeaderContextMenuItems(fieldNum); // Add the current menu items. for (MenuItem currentMenuItem : currentMenuItems) { menuItems.add(currentMenuItem); } // Add custom menu item. MenuItem customMenuItem = new MenuItem("Custom Menu Item"); customMenuItem.addClickHandler(new ClickHandler() { @Override public void onClick(MenuItemClickEvent event) { int colNum = event.getColNum(); String fieldName = getFieldName(colNum); SC.say("columnNum: " + colNum + ", columnName: " + fieldName); } }); menuItems.add(new MenuItemSeparator()); menuItems.add(customMenuItem); return menuItems.toArray(new MenuItem[menuItems.size()]); }
Comment