有2个Ext.data.models(嵌套):
Ext.define('App.Model.Permission', {
extend: 'Ext.data.Model',
belongsTo: 'Roles',
fields: [{ name: 'Controller', mapping: '@Controller' }, 'Ptype'],
});
Ext.define('App.Model.Roles', {
extend: 'Ext.data.Model',
idProperty: 'Id',
hasMany: { model: 'Permission', name: 'Permissions', associationKey: 'Permissions' },
fields: [{ name: 'Id', mapping: '@Id' }, 'Name', 'Description']
});
存储对象 - Ext.store
rolesstore = Ext.create('App.Data.Lstore', {
model: 'App.Model.Roles',
autoLoad: false,
proxy: {
type: 'ajax',
url: '/Cache/roles.xml',
reader: {
type: 'xml',
record: 'Role'
}
}
});
用于数据加载的xml文件的一部分
<?xml version="1.0" encoding="utf-8"?> <Roles> <Role Id="11111111-1111-1111-1111-111111111111"> <Usercreate>430d4bda-4c0c-4e5a-a443-b7091ef1e98c</Usercreate> <Dateedit>01.01.0001</Dateedit> <Name>Администратор</Name> <Description>Роль администратора</Description> <Permissions> <Permission Controller="PurchaseController"> <Ptype>2</Ptype> </Permission> <Permission Controller="ContractController"> <Ptype>2</Ptype> </Permission> <Permission Controller="PlanController"> <Ptype>2</Ptype> </Permission> <Permission Controller="ApprovalController"> <Ptype>2</Ptype> </Permission> <Permission Controller="AdminController"> <Ptype>2</Ptype> </Permission> <Permission Controller="DictionaryController"> <Ptype>2</Ptype> </Permission> </Permissions> </Role> </Roles>
将数据加载到仅存储'角色'模型时,存储时没有嵌套'权限'模型?
哪里出错了? 感谢。