Sencha Touch-如何获取列表itemtpl以显示JSON子对象? [英] Sencha Touch - How to get list itemtpl to display JSON child objects?
本文介绍了Sencha Touch-如何获取列表itemtpl以显示JSON子对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在尝试使用itemtpl属性显示列表时显示子对象时遇到一些问题.这是问题的一个例子
I am having some problems trying to display child objects using itemtpl property for a list. here is an example of the issue
JSON字符串:
{"messages" : [{"body":{"special":"some special format", "plain":"plain format"}}]
型号:
Ext.regModel('MyFeed', {
fields: [
{name: 'body'}
]
});
商店:
var FeedStore = new Ext.data.Store({
model: 'MyFeed',
proxy: {
type: 'ajax',
url: 'data.json',
reader: {
type: 'json',
root: 'messages'
}
}
});
列表:
var FeedList = new Ext.List({
itemTpl : '<div>{body}</div>',
store: FeedStore,
width: '100%',
style: 'background-color: #dfe2e3',
plugins: [{
ptype: 'pullrefresh'
}]
});
推荐答案
您可以设置映射:
Ext.regModel('MyFeed', {
fields: [
{name: 'body'},
{name: 'special', mapping: 'body.special'},
{name: 'plain', mapping: 'body.plain'}
]
});
这篇关于Sencha Touch-如何获取列表itemtpl以显示JSON子对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文