0

有 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>

在加载数据以仅存储“角色”模型时存储而不嵌套“权限”模型?

哪里错了?谢谢。

4

1 回答 1

0

它,只是不能这样工作。指南说您必须显式调用嵌套关联 Roles.Permissions()。请参阅指南示例

于 2012-04-24T02:06:34.430 回答