创建列表并使用 Sencha Touch 从 JSON 源填充它
我在做一件应该很简单的事情却无法让它发挥作用时遇到了麻烦。我尝试了来自不同站点的几个示例,并查看了 Sencha Touch API,但没有成功。我正在尝试的是从外部 JSON 源填充列表。为了使其尽可能简单,我现在只是将其放入外部文件中。
Ext.setup({
tabletStartupScreen: 'tablet_startup.png',
phoneStartupScreen: 'phone_startup.png',
icon: 'icon.png',
glossOnIcon: false,
onReady : function() {
Ext.regModel('Contact', {
fields: ['firstName', 'lastName']
});
var store = new Ext.data.Store({
model: 'Contact',
sorters: 'firstName',
getGroupString : function(record) {
return record.get('firstName')[0];
},
proxy: {
type: 'ajax',
url : 'test.json',
reader: {
type: 'json'
}
}
});
var list = new Ext.List({
fullscreen: true,
itemTpl : '{firstName} {lastName}',
store: store
});
list.show();}});
JSON 文件中
[
{
"firstName" : "pelle",
"lastName": "ollesson"
},
{
"firstName" : "nisse",
"lastName": "pellssdfok"
}
]
是否存在您可以立即看到的错误内容?
提前致谢
Im having trouble with what should be a simple thing to do but cant get it to work. I have tried several examples from different sites and looked and the Sencha Touch API but no luck. What I am trying is to just fill a List from an external JSON source. To make it as simple as possible I've just put it in an external file for now.
Ext.setup({
tabletStartupScreen: 'tablet_startup.png',
phoneStartupScreen: 'phone_startup.png',
icon: 'icon.png',
glossOnIcon: false,
onReady : function() {
Ext.regModel('Contact', {
fields: ['firstName', 'lastName']
});
var store = new Ext.data.Store({
model: 'Contact',
sorters: 'firstName',
getGroupString : function(record) {
return record.get('firstName')[0];
},
proxy: {
type: 'ajax',
url : 'test.json',
reader: {
type: 'json'
}
}
});
var list = new Ext.List({
fullscreen: true,
itemTpl : '{firstName} {lastName}',
store: store
});
list.show();}});
The JSON file
[
{
"firstName" : "pelle",
"lastName": "ollesson"
},
{
"firstName" : "nisse",
"lastName": "pellssdfok"
}
]
Is there something that you can see right away that is wrong?
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好的,解决了。当我删除排序器和 getGroupString 时,它突然起作用了。
Ok, solved. When I removed sorters and getGroupString it suddenly worked.