Extjs Model Fields with Subfields

Does anyone know how you model subfields of any field in ExtJS? for instance

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'},
]

then in my grid panel

Ext.grid.panel

columns:[
    {header:'Title', dataIndex:'title', flex:1},
    {header:'Priority', dataIndex:'code'}
],

Any idea how I access the dataIndex code in the "priority" section? thanks in advance!

+5
source share
2 answers

Thanks @sha - this is the answer I need :)

Model

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'}

         ],
+11
source

Try the following:

dataIndex: 'priority.code'
+4
source

All Articles