Announcement

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

    IPickTreeItem event.cancel not working

    Hello guys.

    I'm using smartGWT 2.5 with Firefox 11.

    I have a IPickTreeItem and for some treeNodeValues I want to prevent the user from clicking them. Keeping that in mind, I was looking into the addChangeHandler method of the IPickTreeItem. I noticed that doing event.cancel did not cancelled the user change. Can you confirm this is a bug ?

    Please see the code below.

    OBS : The javadoc documentation for addChangeHandler is quite confusing :

    Called when a FormItem's value is about to change as the result of user interaction. This method fires after the user performed an action that would change the value of this field, but before the element itself is changed.

    Returning false cancels the change

    Code:
    TreeNode treenode = new TreeNode("root", new TreeNode("Operation A"),
    				new TreeNode("Operation B"));
    
    		final DynamicForm dynamicForm = new DynamicForm();
    
    		Tree tree = new Tree();
    		tree.setRoot(treenode);
    
    		final IPickTreeItem pickTreeItem = new IPickTreeItem();
    		pickTreeItem.setValueTree(tree);
    		pickTreeItem.addChangeHandler(new ChangeHandler()
    		{
    			@Override
    			public void onChange(ChangeEvent event)
    			{
    				event.cancel(); // Do not prevent the change to occur
                                    pickTreeItem.clearValue(); // Not work either
                                    pickTreeItem.setValue((String)null); // Same
    
    			}
    		});
    
    		dynamicForm.setItems(pickTreeItem);
    		dynamicForm.draw();
    Maybe it's a bug, because it's work as expected using a Button. I suspect that the problem come from the event.cancel(). It seems the event is not being cancelled.

    Code:
    TreeNode treenode = new TreeNode("root", new TreeNode("Operation A"),
    				new TreeNode("Operation B"));
    
    		final DynamicForm dynamicForm = new DynamicForm();
    
    		Tree tree = new Tree();
    		tree.setRoot(treenode);
    
    		final PickTreeItem pickTreeItem = new PickTreeItem();
    		pickTreeItem.setValueTree(tree);
    		pickTreeItem.setDefaultValue("sdkfjsdkfj");
    		
    		Button bt = new Button("click");
    		[B]bt.addClickHandler(new ClickHandler()
    		{
    			@Override
    			public void onClick(ClickEvent event)
    			{
    				pickTreeItem.setValue((Object) null);
    			}
    		}); [/B]
    
    		bt.draw();
    		dynamicForm.setItems(pickTreeItem);
    		dynamicForm.draw();
    Regards.
    Last edited by jmichelgarcia; 2 May 2012, 03:53.

    #2
    Can I get any help on this ?
    Please ?

    Comment


      #3
      Originally posted by jmichelgarcia
      Can I get any help on this ?
      Please ?
      Does someone from Isomorphic team have a few minutes to take a look at this post ?
      Last edited by jmichelgarcia; 2 May 2012, 23:59.

      Comment


        #4
        The discussion has continued on StackOverflow.

        http://stackoverflow.com/questions/1...to-be-selected

        I would really appreciate if someone from the staff could take a look at this. We reached a dead end. I would be nice to know if this is a BUG or if we are doing things wrong.

        Comment


          #5
          This was a bug - it should now be resolved in both 3.0p and 3.1d branches (please try the next nightly dated May 17 2012 or greater to get the fix)

          Regards
          Isomorphic Software

          Comment


            #6
            Does this mean it won't be passed to 2.5 or wasn't this bug affecting that version?

            Comment

            Working...
            X