在不使用模型的情况下创建一个简单的TreeStore - Sencha Touch

时间:2012-03-12 14:34:40

标签: sencha-touch extjs sencha-touch-2

我正在尝试创建一个没有模型的简单TreeStore,这就是我所做的:

var store = new Ext.data.TreeStore({
    fields: ['name', 'area', 'children'],
    data: {
        name: 'Budget',
        area: 1,
        children: [{
            name: 'Defense',
            area: 0.5,
            children: []
        }, {
            name: 'Education',
            area: 0.3,
            children: []
        }, {
            name: 'Debt',
            area: 0.2,
            children: []
        }]
    }
});

但是我得到Uncaught TypeError: Cannot call method 'getReader' of undefined,有人可以告诉我我错过了什么吗?

由于

1 个答案:

答案 0 :(得分:1)

您需要指定使用内存代理:

var store = new Ext.data.TreeStore({
    fields: ['name', 'area', 'children'],
    data: {
        text: 'Budget',
        area: 1,
        children: [{
            name: 'Defense',
            area: 0.5,
            children: []
        }, {
            name: 'Education',
            area: 0.3,
            children: []
        }, {
            name: 'Debt',
            area: 0.2,
            children: []
        }]
    },
    proxy : 'memory'
});