admin管理员组文章数量:1406308
I have the following code, but it is not working. The callback
never fires, and so is load listener.
var someDS = new Ext.data.Store({
proxy : new Ext.data.HttpProxy({url : 'someUrl', method : 'GET'}),
reader: new Ext.data.JsonReader({} ['aaa', 'bbb', 'ccc']),
callback : function(options, success, response) {
alert(response);
// some code
},
listeners: {
load : function() {
alert("load");
// some code
}
}
});
I have the following code, but it is not working. The callback
never fires, and so is load listener.
var someDS = new Ext.data.Store({
proxy : new Ext.data.HttpProxy({url : 'someUrl', method : 'GET'}),
reader: new Ext.data.JsonReader({} ['aaa', 'bbb', 'ccc']),
callback : function(options, success, response) {
alert(response);
// some code
},
listeners: {
load : function() {
alert("load");
// some code
}
}
});
Share
Improve this question
edited Nov 2, 2019 at 17:29
Brian Tompsett - 汤莱恩
5,89372 gold badges61 silver badges133 bronze badges
asked Dec 27, 2010 at 23:36
fastcodejavafastcodejava
41.2k31 gold badges139 silver badges191 bronze badges
1 Answer
Reset to default 4your reader definition doesn't look correct to me: is the "{} ['aaa','bbb','ccc']" bit fine?
anyway, this code works with extjs 3.2:
var mystore = new Ext.data.Store({
url: '/your/url/',
autoLoad: true,
reader: new Ext.data.JsonReader({
root: 'rows',
fields: [ 'id', 'field1', 'field2' ]
}),
listeners: {
load: function(t, records, options) {
console.log('test ok');
for (var i=0; i<records.length; i++) {
console.log(String.format('record {0} = {1}', i, records[i].data.id));
}
}
}
});
it works with the following json string returned by the server call at '/your/url/':
{
"rows": [
{
"id": 17,
"field1": "Emiliano",
"field2": 1
},
{
"id": 18,
"field1": "Luca",
"field2": 3
}
],
"total": 2
}
do not confuse the load method and the load event;
do not forget the 'root' parameter in the reader definition (well, actually it's not necessary to have the 'test ok' string printed, but without it you won't get the ids printed by the for loop)
本文标签: javascriptCallback is not firing in ExtJs StoreStack Overflow
版权声明:本文标题:javascript - Callback is not firing in ExtJs Store - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745006151a2637275.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论