English 中文(简体)
在 GXT 3 中单击树的处理器吗?
原标题:Click Handlers for Trees in GXT 3?

我一直在通过" http://dev.sencha.com/deplove/gxt-3.0.0-rc2/javadoc/gxt/com/sencha/gxt/widget/core/client/tree/Tree.html" rel=“nofollow”>GXT3 s Tree API ,寻找某种方法,在我点击或双击树上的节点时执行一项动作,我似乎找不到任何可行的东西。

我知道 TreeGrid CellClickHandler CellDoubleClick 处理器, 但对于 Tree 来说似乎没有什么相似之处。 从 元件 继承的通用 addHandler 方法似乎适用于整个树, 而不是特定的节点 。

有我忽略的东西吗? 还是用不同/更好的方法来做?

问题回答

使用 TreePanel 的选择模式:

treePanel.getSelectionModel().addSelectionChangedListener(
        new SelectionChangedListener<BaseTreeModel>() {

            @Override
            public void selectionChanged(SelectionChangedEvent<BaseTreeModel> se) {

                BaseTreeModel selectedItem = se.getSelectedItem();

                // implement functionality
            }
        }
);

"http://dev.sencha.com/deploy/gxt-2.5/docs/api/com/extjs/gxt/ui/client/widget/tree/Tree.html" rel=“nofollow”_#code>TreePanel API

此选项用于单选

    tree.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
    tree.getSelectionModel().addSelectionHandler(new SelectionHandler<MenuView.MenuDto>() {

        public void onSelection(SelectionEvent<MenuDto> event) {
            MenuDto mnu = event.getSelectedItem();
            Info.display("Tree Handler", mnu.getDescripcion());
        }
    });

用于多个选择

    tree.getSelectionModel().addSelectionChangedHandler(new SelectionChangedHandler<MenuView.MenuDto>() {

        public void onSelectionChanged(SelectionChangedEvent<MenuDto> event) {
            List<MenuDto> mnus = event.getSelection();
            Info.display("Tree Handler", mnus.get(0).getDescripcion());
        }
    });

另一个选项是覆盖 DoubleClick (或 Click) 方法上的树 s :

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);
   }
};

这可以通过使用“细胞行动树”来实现,其实施情况如下:http://www.sencha.com/examples/#ExamplePlace:cellactiontree” rel=“nofollow”>http://www.sencha.com/examples/#ExamplePlace:cellactiontree





相关问题
Listen for Events from Browser "Find" Window in JavaScript

Is there a way to listen for typing into the browser s "find" window in JavaScript? (source: apple.com) I d like to be able to reinterpret the search text from JavaScript. What do I need to ...

Equivalent of PreviewKeyDown of C# needed for native C++/MFC

I used a ActiveXControl in a C# Forms application and had the possibility to implement a PreviewKeyDown event handler for that ActiveXControl. That was needed to specify that, e.g. the [ALT] key, is ...

Refresh the UI in gwt

I have created some custom composite widget, which listens to an events (in my case loginEvent). Once the event is caught the state of the widget changes so as the way it should look (in my case I ...

How to remove "onclick" with JQuery?

PHP code: <a id="a$id" onclick="check($id,1)" href="javascript:void(0)" class="black">Qualify</a> I want to remove the onclick="check($id,1) so the link cannot be clicked or "check($id,...

热门标签