没有用于TreePanel的URL的ExtJS存储

时间:2013-10-31 13:24:31

标签: javascript json 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();

我的问题: 我可以用这个url json商店加载我的treegrid。但我想用来自服务器的解码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对象,我的树面板不会显示文本。

1 个答案:

答案 0 :(得分:1)

使用memory proxyroot配置:

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