2013-10-31 94 views
0

型號:ExtJS的庫而不網址TreePanel中

Ext.define('Product', { 
    extend: 'Ext.data.Model', 
    fields: [ 
     {name: 'product',  type: 'string'}, 
//  {name: 'active',  type: 'string'}, 
     {name: 'balance', type: 'string'} 
    ] 
}); 

商店:

var store = Ext.create('Ext.data.TreeStore', { 
     model: 'Product', 
     proxy: { 
      type: 'ajax', 
      url: 'treegrid.json' 
     }, 
     folderSort: true 
    }); 

的TreeGrid:

var tree = Ext.create('Ext.tree.Panel', { 
     title: 'Core Team Projects', 
     width: 500, 
     height: 300, 
     renderTo: Ext.getBody(), 
     collapsible: true, 
     useArrows: true, 
     rootVisible: false, 
     store: store, 
     multiSelect: true, 
     singleExpand: true, 
     //the 'columns' property is now 'headers' 
     columns: [{ 
      xtype: 'treecolumn', 
      text: 'Ürün', 
      flex: 2, 
      sortable: true, 
      dataIndex: 'product' 
     },{ 
      text: 'Bakiye', 
      flex: 1, 
      dataIndex: 'balance', 
      sortable: true 
     }] 
    }); 
    this.add(tree); 
    this.doLayout(); 

我的問題: 我能載入我的TreeGrid與此網址json商店。但我想加載解碼的json對象,它來自服務器。類似下面:

商店:

var store = Ext.create('Ext.data.TreeStore', { 
     model: 'Product', 
     root: inData, 
     folderSort: true 
    }); 

INDATA:

{"text":".", 
"children":[ 
{"product":"Mevduat","balance":"15000","expanded":"true","children":[ 
     {"product":"Vadesiz Mevduat","balance":"7000","expanded":"true","children":[ 
     {"product":"Vadesiz Hesap","balance":"3500","leaf":"true"}, 
     {"product":"fk Hesap","balance":"3500","leaf":"true"} 
     ] 
    }, 
    {"product":"Vadeli Mevduat","balance":"8000","expanded":"true","children":[ 
     {"product":"Kirik Vadeli Hesap","balance":"3000","leaf":"true"}, 
     {"product":"Birikimli Gelecek Hesabı","balance":"5000","leaf":"true"} 
    ]}] 
}, 
    {"product":"Bireysel Krediler","balance":"40000","expanded":"true","children":[ 
     {"product":"Konut Kredisi","balance":"15000","leaf":"true"}, 
     {"product":"Arsa Kredisi","balance":"25000","leaf":"true"} 
    ] 
}]} 

但是,如果使用INDATA JSON對象,我的樹面板不顯示文本。

+0

u能提供的小提琴 – Asif

+0

得到了答案。我只需使用類型:內存代理。有人回答,但後來刪除它。非常感謝你。 –

+0

我刪除了它,因爲在我的小提琴中它也沒有內存代理工作,所以我覺得還有另一個問題。很高興它幫助你解決了你的問題:) – matt

回答

1

使用memory proxyroot配置:

var store = Ext.create('Ext.data.TreeStore', { 
    model: 'Product', 
    proxy: { 
     type: 'memory' 
    }, 
    root: inData, 
    folderSort: true 
}); 
+0

男人,我一直在這工作超過3天,你也給我帶來了解決方案,非常感謝你! –