Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extjs Model Fields with Subfields

Anyone know how you model subfields of any field in ExtJS? For example

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' under 'priority'? thanks in advance!

like image 457
Stevanicus Avatar asked May 08 '12 14:05

Stevanicus


2 Answers

Thanks to @sha - here is the answer I needed :)

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

         ],
like image 181
Stevanicus Avatar answered Oct 17 '22 15:10

Stevanicus


Try this:

dataIndex: 'priority.code'
like image 40
sha Avatar answered Oct 17 '22 15:10

sha