-1
我正在与触发2.4项目的sencha架构师合作。我有一个问题处理嵌套列表和树店:
这是我的店:
Ext.define('App.store.Tree', { extend: 'Ext.data.TreeStore', requires: [ 'App.model.Servicios', 'Ext.data.proxy.Ajax', 'Ext.data.reader.Json', 'Ext.data.proxy.LocalStorage' ], config: { model: 'App.model.Servicios', storeId: 'Tree', defaultRootProperty: 'items', proxy: { type: 'ajax', type: 'localstorage', reader: { type: 'json' } } }
});
(我试过用proxys和读者的每个组合和错误是一样的。)
现在,这是我的模型:
Ext.define('App.model.Servicios', { extend: 'Ext.data.Model', requires: [ 'Ext.data.Field' ], config: { fields: [ { name: 'categoria', type: 'string' }, { name: 'nombre', type: 'string' }, { name: 'ubicacion', type: 'string' }, { name: 'datos', type: 'string' } ] } });
这是带有嵌套列表的容器:
Ext.define('App.view.ServiciosContainer', { extend: 'Ext.Container', alias: 'widget.servicioscontainer', requires: [ 'Ext.Toolbar', 'Ext.Button', 'Ext.dataview.NestedList' ], config: { height: '100%', id: 'ServiciosContainer', width: '100%', layout: 'fit', items: [ { xtype: 'toolbar', docked: 'top', items: [ { xtype: 'button', id: 'serviciosContainerHome', iconCls: 'list' }, { xtype: 'button', id: 'serviciosContainerBorrar', iconCls: 'trash' }, { xtype: 'button', id: 'serviciosContainerAgregar', iconCls: 'add' } ] }, { xtype: 'nestedlist', id: 'lstServicios', displayField: 'nombre', store: 'Tree' } ] }, });
Add按钮执行以下操作:
var data = { items: [ { nombre: '1', items: [{ nombre: '1.1', items: [{ nombre: '1.1.1 last', leaf: true }, { nombre: '1.1.2 last', leaf: true }] }, { nombre: '1.2 last', leaf: true }] }, { nombre: '2', items: [{ nombre: '2.1 last', leaf: true }, { nombre: '2.2 last', leaf: true }] } ] }; var servicios = Ext.getStore('TreeStore'); servicios.add(data);
这是我的错误,当我尝试将数据添加到商店:
TypeError: null is not an object (evaluating 'children.length')
请帮助!!!!我不知道在哪里寻找错误,因为我发现的所有例子与我的相同,并且他们没有任何问题。