jsonstore加载的数据如下:
"[{"Year":"2014","Total":"5.6","Rank":"6","Share":"6"},
{"Year":"2013","Total":"5.6","Rank":"6","Share":"6"},
{"Year":"2014","Total":"5.6","Rank":"6","Share":"6"},
{"Year":"2013","Total":"5.6","Rank":"6","Share":"6"}]"我们需要迭代响应:
FeesByProduct_store = new Ext.data.JsonStore({
root: 'list',
url: '...............',
fields: FeeByProduct,
listeners: {load: function(store) {
//create a json object from the response string
var res = Ext.encode(Ext.pluck(store.data.items, 'data'));
// if we have a valid json object, then process it
if(res !== null && typeof (res) !== 'undefined'){
// loop through the data
Ext.each(res, function(obj){
//add the records to the array
if (obj != null) {
...
}
});
}
}
}
}); 但是,在迭代时- 'obj‘包含响应的整个值,而不是一次包含每一行。
这里到底做错了什么?
发布于 2014-08-25 03:20:31
如果您已经成功地加载了存储,那么原来的json就不再有意义了。在商店上有很多方法可以用来检查或操作商店记录。
您的加载侦听器可能如下所示:
load:function() {
this.each(function(record) {
// do something with record here, for example
console.log(record.getData();
}
}检查store documentation,查找您可以用来实现所需内容的其他方法。
https://stackoverflow.com/questions/25474525
复制相似问题