单击GXT 3中的树的处理程序? [英] Click Handlers for Trees in GXT 3?
问题描述
我一直在查看 GXT3的树
API ,以便在单击或双击某个节点时执行某个操作树,我似乎找不到任何可以工作的东西。
I've been looking through GXT3's Tree
API for some way to execute an action when I click or double click on a node in a tree, and I can't seem to find anything that would work.
我知道 TreeGrid
有一个 CellClickHandler
和 CellDoubleClick
处理程序,但似乎没有什么类似的 Tree
。有从 Widget
继承的通用 addHandler
方法,但这似乎适用于整个树,而不是特定的节点
I know TreeGrid
has a CellClickHandler
and CellDoubleClick
handler, but there doesn't seem to be anything similar for Tree
. There's the generic addHandler
method inherited from Widget
but this seems like it would apply to the whole tree, not a specific node.
有没有什么我可以俯瞰,还是一个不同的/更好的方法呢?
Is there something I'm overlooking, or a different / better way to do this?
推荐答案
另一个选项是覆盖Tree的onDoubleClick(或onClick)方法:
Another option is to override Tree's onDoubleClick (or onClick) method:
Tree tree = new Tree<MyModel, String>(store, valueProvider){
@Override
protected void onDoubleClick(Event event) {
TreeNode<MyModel> node = findNode(event.getEventTarget().<Element> cast());
Info.display("Double Click", "You double clicked this node!");
super.onDoubleClick(event);
}
};
这篇关于单击GXT 3中的树的处理程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!