PDA

View Full Version : List itemtpl display JSON child objects



rbrookfield
16 Jul 2011, 4:34 PM
Hi everyone. I am having some problems trying to display child objects using itemtpl property for a list. here is an example of the issue

JSON string

{"messages" : [{"body":{"special":"some special format", "plain":"plain format"}}]

Model

Ext.regModel('MyFeed', {
fields: [
{name: 'body'}
]
});

Store

var FeedStore = new Ext.data.Store({
model: 'MyFeed',
proxy: {
type: 'ajax',
url: 'data.json',
reader: {
type: 'json',
root: 'messages'
}
}
});

List

var FeedList = new Ext.List({
itemTpl : '<div>{body}</div>',
store: FeedStore,
width: '100%',
style: 'background-color: #dfe2e3',
plugins: [{
ptype: 'pullrefresh'
}]
});

When i put in {body} in the itemTpl the response is [Object-object]. If i put in {plain} I dont get any response back. Am I doing something wrong? I would love any advice/help. I have also tried adding new Ext.regModel for plain and added a belongsTo property, but that didnt appear to work either.