2014-03-13 37 views
-2

因爲我對Extjs非常陌生,所以我想知道使用它創建樹。我需要一個簡單的例子來創建一個根和一個孩子。任何人都可以幫助我嗎?如何在Extjs中創建樹

+2

有在文檔的例子不勝枚舉的例子。 –

回答

0

如果你是新來的Extjs,你必須知道,你可以找到很多的例子HERE。 有關靜態樹面板的示例,請參閱下面的示例:

要使樹面板工作,首先需要有一些數據。通過TreeStore實例加載數據將在內部解析關係並將所有與樹相關的方法應用於模型實例。

TreeStore

var store = Ext.create('Ext.data.TreeStore',{ 
    // Sets up root node 
    root : { 
     text: 'Root Node', 
     expanded : true, // Expands true node on initialization 
     children :[{ // Specifies child nodes 
      text:'Child 1', 
      leaf : true // Specifies node as leaf 
     },{ 
      text:'Child 2', 
      leaf : true 
     },{ 
      text : 'Child 3', 
      children: [{ 
       text : 'Grand Child 1', 
       children : [{ 
        text: 'etc.', 
        leaf : true 
       }] 
      }] 
     }] 
    } 
}); 

TreePanel中

Ext.create('Ext.window.Window',{ 
    title : 'Title window', 
    layout: 'fit', 
    autoshow : true, 
    height : 200, 
    width : 200, 
    items : { // Here, you configure your tree panel 
     xtype: 'treepanel', 
     border : false, 
     store : store, // Store created above 
     rootVisible : true 
    } 
}); 

您也可以找到一個JSON文件HERE