如何从服务器加载网格中的数据我能够将数据从存储加载到网格,但无法将数据从服务器加载到存储,然后再加载到网格服务器 API 详细信息:
http://192.1681.102:8080/Petcrumbs/member/getMemberList
请求参数:
{"pageNumber":5}
响应成功:
{ "listOfMembers": [ { "address": { "state": "MH", "country": "India", "city": "Pune", "addressId": 52, "streetName": "Karve Road" ,“streetNameTwo”:“Nal Stop”,“zipCode”:“412042”},“name”:“Test Mmber4”,“password”:“287974”,“authKey”:“99710ff8d98346f51a7b3df83c16257”,“gender”:“Male ", "deviceToken": "ldjhakjhdkjahn42,n4lk2jedlkandmandlkand", "community": "Kothrud", "emailId": "r.pekam@mb.com", "phone": "9096305571", "image": null, "memberId": 41, "active": 1, "deleted": false, "myPackage" : "Gold", "joinedDate": "09-17-2013" } ], "message": "会员检索成功。", "success": true }} ], "message": "会员检索成功。", "success": true }} ], "message": "会员检索成功。", "success": true }
响应失败:
{ "listOfMembers": null, "message": "无法检索成员。", "success": false
}
在 EXTJS 商店中
Ext.define('PetCrumbs.store.Members', {
extend : 'Ext.data.ArrayStore',
model : 'PetCrumbs.model.Member',
autoLoad : true,
//storeId : 'Data',
proxy : {
type : 'ajax',
url : '/Petcrumbs/member/getMemberList',
method : 'POST',
headers : {
'Content-Type' : 'application/json',
'Accept' : 'application/json'
},
jsonData : {
pageNumber : "5"
},
reader : {
type : 'json',
root: 'listOfMembers',
successProperty: 'success'
}
}
});
当我有这样的存储(硬编码数据)时,网格会显示数据:
Ext.define('PetCrumbs.store.Members', {
extend: 'Ext.data.ArrayStore',
model: 'PetCrumbs.model.Member',
data: [
['1','1002','Asin','kothroud@gmail.com','kothrud,Pune','MH',
'Pune','411051','Male','Gold','Kothrud','1'],['2','1012','Karina','Pashan@gmail.com',
'Pashan,Pune','MH','Pune','411051','Female','Silver','Pashan','0']
]
});
请告诉我上面的代码有什么问题?