这里是使用Sencha touch2的列表代码,我有一个休息服务,我需要能够加载我的商店列表视图。关注
var tab= Ext.create('Ext.List', {
width: 320,
height: 290,
store: {
fields: ['ext_xtype','imgURL','arimg'],
data: [{
ext_xtype: 'Harry Potter 4',
imgURL:'bo.png',
arimg:'arrow.png'
},{
ext_xtype: 'Iphone5 64gb',
imgURL:'mo.png',
arimg:'arrow.png'
},{
ext_xtype: 'Hill Figure',
imgURL:'wa.png',
arimg:'arrow.png'
}]
},
itemTpl: '<img src="{imgURL}" width="35" heigh="35"></img><span>   {ext_xtype}<img src="{arimg}" width="25" height="25" align="right"></img>'
});
我尝试了以下链接Sencha with proxy quest,但无法继续。继续使用其他JSON方法。
Method: GET
URL: http://117.218.59.157:8080/WishList/ShowItems/userID=?
如何导入json以在LIST中加载
#EDIT
var tab= Ext.create('Ext.List', {
width: 320,
height: 290,
//ui: 'round',
store: {
proxy: {
type: 'ajax',
url: 'http://117.218.59.157:8080/WishList/ShowItems/userID=1',
reader: {
type: 'json'
}
}
fields: [
{ imgURL: 'itemID' },
{ ext_xtype: 'itemName'},
{ arimg: 'itemImage'},
],
},
itemTpl: '<img src="{imgURL}" width="35" heigh="35"></img><span>   {ext_xtype}<img src="{arimg}" width="25" height="25" align="right"></img>'
});
答案 0 :(得分:1)
您忘记设置JSON阅读器的root
和idProperty
!它应该如下所示:
proxy: {
type: 'ajax',
url: 'http://117.218.59.157:8080/WishList/ShowItems/userID=1',
method: 'GET'
},
reader: {
type: 'json',
root: 'items',
idProperty: 'itemID'
}
此外,您的JSON数据应如下所示:
{"items":
[{
"itemID": "1",
"errorMsg": "",
"itemName": "Airplane",
"itemDesc": "Model NEW 2003"
},
{
"itemID": "2",
"errorMsg": "",
"itemName": "Bike",
"itemDesc": "Model NEW 2003"
}
]
}