在Ext GWT 3.0 Tree中展开并选择节点

时间:2012-05-16 09:29:18

标签: java gxt uibinder

我在我的布局的第一个内容窗格中添加了一个带有树的手风琴布局容器。不,一个需求调用扩展并在加载应用程序时选择一个节点(它是一个模型)。

然后我将它添加到类的构造函数中,与uibinder布局相对应:

widget = uiBinder.createAndBindUi(this);               // everything's bound

accordionLayoutContainer.setActiveWidget(firstPanel);  // OK, expands first pane
tree.getSelectionModel().select(mynode, true);        // no visible effect
tree.setExpanded(mynode, false);                       // no visible effect

这里缺少什么?在设置状态后是否必须强制“某事”的布局?或者选择和扩展节点是错误的地方?

1 个答案:

答案 0 :(得分:3)

找到解决方案。必须延迟对setExpand的调用,直到附加了树。所以我在父窗口小部件中添加了一个AttachEvent.Handler - 将它直接添加到树中是行不通的,因为在模型注册之前会先调用处理程序。

widget = uiBinder.createAndBindUi(this);               // everything's bound

accordionLayoutContainer.setActiveWidget(firstPanel);  // OK, expands first pane
accordionLayoutContainer.addAttachHandler(new AttachEvent.Handler() {

  @Override
  public void onAttachOrDetach(AttachEvent event) {
    clientsTree.getSelectionModel().select(mynode, true);
    clientsTree.setExpanded(mynode, true);              
  }
});
相关问题