2013-04-02 77 views
0

我已經通過將xtype指定爲樹列來創建樹面板。我想選擇樹的第一片葉子。在這個例子中我已經註冊了boxready活動詳情如下:樹的第一個節點的選擇不會在xtype樹列中發生

boxready : function(treePanel, width, height, eOpts){ 

    treePanel.getSelectionModel().select(0); 
    //treePanel.select(treePanel.getRootNode().getChildAt(0)); 
    treePanel.getSelectionModel().selected = 0; 
}, 
treePanel.getSelectionModel() 

這個例子給我型單selectionModel設置。任何人都可以解釋爲什麼我的例子不選擇第一片葉子?

回答

0

這是一個小 「圖」:

如果需要從開頭葉:

選擇
  • 一個節點:

    變種NODEDATA = treePanel.getSelectionModel()getSelection ();

  • 的開始:

    VAR節點= treePanel.getRootNode(); - 父親(第一個節點);

    findLeaf:函數(節點) {

    if(node.isLeaf()){ 
    // this is the node that u want 
    }else{ 
        // bucle to find it 
        node.eachChild(function(nodeChild,array){ 
         if(nodeChild.isLeaf()){ 
          // this is the node that u want 
         }else{ 
          // get childs of this node 
          if(nodeChild.hasChildNodes()){ 
           //find the childs from this node. 
           this.findLeaf(nodeChild); 
          } 
         } 
        }); 
    } 
    

    };

+0

在我的情況不存在節點選擇,所以我通過 VAR節點= treePanel.getRootNode()得到了節點;但在組件裏面我得到了0項的childNodes,所以它不會foreach循環。你能告訴我我失蹤的地方嗎? – user2211050

+0

如果你沒有選擇一個,你需要獲取根節點。也許,你可以從樹木商店得到它。 但即時通訊認爲,它存儲其空,即錯誤... – mfruizs2

+0

是的,你是對的。那時候商店是空的。所以我將代碼移動到store.onload,現在它的工作正常。 – user2211050

相關問題