I m试图在上澄清用户选定的价值。
这是在上发现的唯一解决办法,即限制使用者选择某些树根值(并非全部)。
To be more clear, it seems that calling event.cancel() do not stop the event from bubbling.
我做了一些错误?
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)
{
pickTreeItem.clearValue() // Not clearing the value
pickTreeItem.setValue((String)null) // Not working neither
event.cancel() // Not seeming to work...
}
});
dynamicForm.setItems(pickTreeItem);
dynamicForm.draw();
http://www.ohchr.org。
pickTreeItem.setInputTransformer(new FormItemInputTransformer()
{
@Override
public Object transformInput(DynamicForm form, FormItem item,
Object value, Object oldValue)
{
return "Desired New Value (not working)...";
}
});
之所以如此,是因为it利用外部布顿来清理价值。 (除小块田外)
Button bt = new Button("click");
bt.addClickHandler(new ClickHandler()
{
@Override
public void onClick(ClickEvent event)
{
pickTreeItem.setValue((Object) null);
}
});
Expected behavior
我的树木:
-aaaa
----bbbb
----cccc
-dddd
----eeee
----ffff
如果用户选择“aaa”类,PickTreeItem值应当重新回到默认Value(“Choose a Value”),可选择通知用户他不能“aaaa”。
PickTreeItem应当接受“dddd”作为有效的选择价值。