1

Is there a way using the treegrid in gwt-ext to have different context menus for different rows?

For example I would like my leaf rows to have different menu options then my non-leaf rows, or at least be able to disable menu options when they aren't revelent to the row that was right clicked.

4

1 回答 1

0

我为这个问题创建了一个解决方案:

创建叶子时,应将属性“type”设置为“leaf”,其他属性设置为“non-leaf”。

BaseTreeModel base = new BaseTreeModel(); base.set("类型", "叶子");

因此,在您的树的 selectionChanged 事件中,您放置了验证,并仅为您的叶子创建菜单。

  *treePanel.getSelectionModel().addListener(Events.SelectionChange, new      SelectionChangedListener<ModelData>() {
        @Override
        public void selectionChanged(SelectionChangedEvent<ModelData> data) {
            BaseTreeModel selected = (BaseTreeModel) data.getSelectedItem();
            if ("leaf".equals(selected .get("type").toString())) {
            // create the Menu and set it to contextMenu of your tree
            } else {
                treePanel.setContextMenu(null);
            }*

安德烈。

于 2013-10-21T19:29:04.843 回答