任何人都知道如何为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 :(得分: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'},
]
Gird Panel
columns:[
{header:'Title', dataIndex:'title', flex:1},
{header:'Description', dataIndex:'description'},
{header:'Priority', dataIndex:'code'}
],
答案 1 :(得分:4)
试试这个:
dataIndex: 'priority.code'