[英]Expand and select node in Ext GWT 3.0 Tree
我在其第一個內容窗格中添加了一個帶有樹的手風琴布局容器到我的布局。 不,需求調用擴展並在加載應用程序時選擇一個節點(它是一個模型)。
然后我將它添加到類的構造函數中,它與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
這里缺少什么? 設置狀態后是否必須強制“某事”的布局,或者選擇和擴展節點是否錯誤?
找到了解決方案。 必須延遲對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);
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.