带有子字段的Extjs模型字段

带有子字段的Extjs模型字段,extjs,model,grid,field,Extjs,Model,Grid,Field,有人知道如何在ExtJS中为任何字段的子字段建模吗?比如说 Ext.data.Model: fields:[ {name: 'id', type: 'int'}, {name: 'title', type: 'string'}, {name: 'description', type: 'string'}, {name: 'priority', type: 'auto', fields:[ {name: 'code', type: 'string'} ]}

有人知道如何在ExtJS中为任何字段的子字段建模吗?比如说

Ext.data.Model:

fields:[
   {name: 'id', type: 'int'},
   {name: 'title', type: 'string'},
   {name: 'description', type: 'string'},
   {name: 'priority', type: 'auto', fields:[
      {name: 'code', type: 'string'}
   ]},
   {name: 'createdBy', type: 'auto'},
]
然后在我的网格面板中

Ext.grid.Panel

columns:[
    {header:'Title', dataIndex:'title', flex:1},
    {header:'Priority', dataIndex:'code'}
],
知道我如何访问“优先级”下的数据索引“代码”吗?提前谢谢

试试这个:

dataIndex: 'priority.code'

感谢@sha-以下是我需要的答案:)

模型

网格板

columns:[

             {header:'Title', dataIndex:'title', flex:1},
             {header:'Description', dataIndex:'description'},
             {header:'Priority', dataIndex:'code'}

         ],

您可以使用模型的
映射
功能从JSON/XML数据源的嵌套信息中获取标量字段吗?谢谢您。。。映射再次成为关键。。。文档记录不良:)这也适用,但仅适用于不为空的记录。如果优先级为null,它将尝试获取null的代码字段,这将导致错误。@sha:它按照我上面所说的方式运行,对于我的存储,我使用了
映射:“relatedProductType.id”
来摆脱null异常。但是,它仍然让我
无法读取null的属性“id”
。你有什么想法吗?在这里你可以看到我对一个类似问题的例子:
columns:[

             {header:'Title', dataIndex:'title', flex:1},
             {header:'Description', dataIndex:'description'},
             {header:'Priority', dataIndex:'code'}

         ],