2012-05-08 57 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