Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    Contextual menu default closing when MenuItem is clicked

    Hi all, i'm trying to create a button that, when pressed, shows contextual menu that shows/hides the ListGridFields on a ListGrid.

    I'm create a list of MenuItems for each ListGridField in my ListGrid; but when i click a menuItem, contextual menu disappears.

    This is a unexpected behaviour for me; i want achieve that when a menuItem is clicked, contextual menu doesn't disappear.

    I simply want reproduce the function presents in default contextual menu that determines what columns in listGrid are visible.

    I'm using Firefox ESR 17.0.6 and SmartGwt 3.0 -p

    This is my function
    Code:
     public ToolStripMenuButton getColumnMenuButton() {
            final Menu menu = new Menu();
            menu.setMargin(60);
            for (final ListGridField lgf :getListGrid().getFields()) {
                final String fieldName = lgf.getName();
                final MenuItem item = new MenuItem(lgf.getTitle());
    
                item.addClickHandler(new com.smartgwt.client.widgets.menu.events.ClickHandler() {
    
                    @Override
                    public void onClick(MenuItemClickEvent event) {
                        if (getListGrid().fieldIsVisible(fieldName)) {
                            getListGrid().hideField(fieldName);
                        } else {
                            getListGrid().showField(fieldName);
                        }
                    }
                });
                menu.addItem(item);
                item.setCheckIfCondition(new MenuItemIfFunction() {
    
                    @Override
                    public boolean execute(Canvas target, Menu menu, MenuItem item) {
                        return getListGrid().fieldIsVisible(fieldName);
                    }
                });
            }
    
            ToolStripMenuButton menuButton = new ToolStripMenuButton("", menu);
            String imgHTML = Canvas.imgHTML("suite/action/options_16.png");
            menuButton.setTitle("<span>" + imgHTML + "&nbsp;</span>");
    
            return menuButton;
    
        }
    I'm also trying to force a menu.show() at the end of ClickHandler; so contextual menu "seems" doesn't close, but in this work around; checkIfCondition doesn't work!

    #2
    Hi folks,
    I resolved my problem just adding
    Code:
    menu.setAutoDismiss(false);

    Comment

    Working...
    X