Announcement

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

    SmartGwt Menu Menuitem does not get enabled

    Hi,

    I am working on SmartGwt 1.7

    I have a context menu that will appear on right clicking of any record of a grid. Depend upon the value of the clicked grid record, the context menu has to show the menu items either in enabled or disabled status.

    But the menu items are not shown as enabled even if it supposed to be enable. However on focusing that menu item by mouse pointer it get enabled. Enabled in the sense the color of the menu becomes black from grayed color.

    Likewise, the menu item are(is) in enable status, though it should be in disable status. that means it is in black color rather than grayed. However it is not clickable though it is in black color.

    I have attached the code with this thread.

    Any advise to fix this is appreciated.

    Thanks, Arulselvan
    Attached Files

    #2
    Your explaination is ambigious but if you read the docs:

    Code:
    public void setEnabled(java.lang.Boolean enabled)
    
        Affects the visual style and interactivity of the menu item. If set to false, the menu item will not respond to mouse rollovers or clicks.
    
        If you need to set this state dynamically, use enableIf(com.smartgwt.client.widgets.Canvas, com.smartgwt.client.widgets.menu.Menu, com.smartgwt.client.widgets.menu.MenuItem) instead.
    Since you need things to change dynamically, don't use setEnabled, simple as that.

    Comment


      #3
      Hi,

      It seems that defining setEnableIfCondition after creation/adding the menuItem to a parent, doesn't have any effect?

      My enableIf function depends on something else, so the function is defined a bit later, but the function is never called.
      If I set it right after the menuItem definition, then it does work.


      this is a ToolStrip
      Code:
      		Menu menu = new Menu();
      		MenuItem menuItem = new SilkMenuItem("Option");
      		//Assign function here and it's OK
      //		menuItem.setEnableIfCondition(new MenuItemIfFunction() {
      //
      //			public boolean execute(Canvas target, Menu menu, MenuItem item) {
      //				return false;
      //			}
      //		});
      		menu.setItems(menuItem);
      		ToolStripMenuButton menuButton = new ToolStripMenuButton("Options", menu);
      
      		this.addMenuButton(menuButton);
      
      		//Assign later doesn't work?
      		menuItem.setEnableIfCondition(new MenuItemIfFunction() {
      
      			public boolean execute(Canvas target, Menu menu, MenuItem item) {
      				return false;
      			}
      		});
      Tried setting setEnabled, but that shouldn't be used to have the dynamic enabled/disabled effect.

      SmartGWT SC_SNAPSHOT-2011-05-31

      Comment


        #4
        It can't be added later, so just add it immediately and ensure it returns the right value up until the moment when you would otherwise have first added it.

        Comment

        Working...
        X