PDA

View Full Version : Display nested json value in form



riya_phoenix
27 May 2010, 9:23 AM
Hi,
I have a form that displays employee name and address which is a nested json object. How do i get address value to be displayed in the form. Can i do something like this?



Form Code

{
xtype : 'form',
items :
[
{
xtype : 'displayfield',
name : 'name',
fieldLabel : 'Name'
},
{
xtype : 'displayfield',
name : 'previousName',
fieldLabel : 'Previous Name'
},
{
xtype : 'displayfield',
data : 'address',
tpl : new Ext.XTemplate(
'<tpl >',
'<p>{addressLine1}<br/>',
'{addressLine2}<br/>',
'{city}{state}<br/>',
'{countryCode}{zipCode}</p>',
'</tpl>'),
fieldLabel : 'Address'
}
]
}


JSON Response
{"data":{"previousName":null,"address":{"addressLine2":null,"state":"AZ","city":"PRESCOTT","addressLine1":"1100 E SHELDON ST","zipCode":86301,"countryCode":"US"},"name":"John Smith"},"success":true}


Thanks
Riya