2013-06-13 71 views
2

我加載帶有擴展項目(在我的JSON定義的),但是,當它顯示它不是擴張了TreePanel中。的ExtJS TreePanel中沒有展開

只需將DIR(圖標)是開放的,但項目不會顯示。我加載它使用加載存儲功能來重新加載我的treepanel。

enter image description here

storeTree = me.getTreePersonneStore(); 

      storeTree.load({ 
       params: { 
       idPersonne: batch.proxy.getReader().jsonData.id, 
       lettrePersonne: batch.proxy.getReader().jsonData.lettre 
       } 
      }) 

我的店:

Ext.define('ModuleGestion.store.TreePersonne', { 
    extend: 'Ext.data.TreeStore', 

    requires: [ 
     'ModuleGestion.model.Personne' 
    ], 

    constructor: function(cfg) { 
     var me = this; 
     cfg = cfg || {}; 
     me.callParent([Ext.apply({ 
      autoLoad: true, 
      model: 'ModuleGestion.model.Personne', 
      storeId: 'StoreTreePersonne', 
      root: { 
       expanded : true, 
       text : 'Personnes', 
       expandable : true, 
       id : 'root', 
       nodeType:'async', 
       uiProvider:false 
      }, 
      proxy: { 
       type: 'ajax', 
       node: 'id', 
       url: 'ModuleGestion/php/TreePersonne.php', 
       reader: { 
        type: 'json' 
       } 
      }, 
      listeners: { 
       beforeload: { 
        fn: me.beforeload, 
        scope: me 
       } 
      } 
     }, cfg)]); 
    }, 

    beforeload: function(store, operation, eOpts) { 
     operation.params.node = operation.node.get("id"); 
    } 

}); 

我的JSON:

[{ 
    id:"A", 
    text:"A", 
    expanded:true, 
    children:[ 
    { 
     id:"101",text:"AA AA",leaf:true}, 
     {id:"98",text:"AA AA",leaf:true}, 
     {id:"86",text:"AA AA",leaf:true}, 
     {id:"99",text:"AA AA",leaf:true}, 
     {id:"96",text:"AA AA",leaf:true}, 
     {id:"100",text:"AA AA",leaf:true}, 
     {id:"97",text:"AA AA",leaf:true}] 
    }], 
}] 

我的樹:

{ 
    xtype: 'treepanel', 
    id: 'TreePersonne', 
    store: 'TreePersonne', 
    viewConfig: { 
    } 
} 

回答

0

請嘗試以下json。兒童也有擴大財產。

[{ 
    id:"A", 
    text:"A", 
    expanded:true, 
    children:[ 
    { 
     id:"101",text:"AA AA",leaf:true, expanded:true}, 
     {id:"98",text:"AA AA",leaf:true, expanded:true}, 
     {id:"86",text:"AA AA",leaf:true, expanded:true}, 
     {id:"99",text:"AA AA",leaf:true, expanded:true}, 
     {id:"96",text:"AA AA",leaf:true, expanded:true}, 
     {id:"100",text:"AA AA",leaf:true, expanded:true}, 
     {id:"97",text:"AA AA",leaf:true, expanded:true}] 
    }], 
}] 

或者,您也可以展開面板加載後的孩子太爲:

YOUR_TREE_PANEL.expandChildren(true);