2012-05-08 59 views
5

任何人都知道如何模拟ExtJS中任何字段的子字段?例如带子字段的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 '代码'在'优先'下?提前致谢!

+0

在这里,你可以回答看到我的例子到一个类似的问题:http://stackoverflow.co米/一/ 12694550/1496088 –

回答

11

感谢@sha - 这里是我需要:)

型号

fields:[ 

      {name: 'id', type: 'int'}, 
      {name: 'title', type: 'string'}, 
      {name: 'description', type: 'string'}, 
      {name: 'priority', type: 'auto'}, 
      {name: 'code', type: 'string', mapping:'priority.code'}, 
      {name: 'createdBy', type: 'auto'}, 

     ] 

网格面板

columns:[ 

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

     ], 
4

试试这个:

dataIndex: 'priority.code' 
+0

是啊,这是我的想法。 Did not for me :( – Stevanicus

+3

你可以使用模型的'mapping'特性从你的JSON/XML数据源的嵌套信息中获得标量字段吗? – sha

+0

感谢那个...映射再次是关键...记录不完善:) – Stevanicus