[英]Lazy load hasMany association in ExtJS
I'm trying to implementing Lazy loading in ExtJS 4 like this example: http://dev.sencha.com/deploy/ext-4.0.0/examples/data/associations.html using this Code: 我正在尝试像以下示例一样在ExtJS 4中实现延迟加载: http : //dev.sencha.com/deploy/ext-4.0.0/examples/data/associations.html使用以下代码:
/* Models */
Ext.define('Post', {
extend: 'Ext.data.Model',
fields: ['title'],
proxy: {
type: 'ajax',
url: 'http://example.com/post.json'
}
});
Ext.define('User', {
extend: 'Ext.data.Model',
fields: ['name'],
hasMany: 'Post',
proxy: {
type: 'ajax',
url : 'http://example.com/user.json'
}
});
/* Load User and Posts */
User.load(1, {
success: function(user) {
var test = user.posts();
test.on('load', function(me) {
console.log(me.getCount()); /* THIS is always 0?! */
});
test.load();
}
});
/* Returned JSON Data */
/* User */
[{"name":"blalala"}]
/* Posts */
[{"title":"dfgdfgdgd"}]
but the returned Posts-Store is always empty (0 Records). 但是返回的Posts-Store始终为空(0条记录)。 You can check my JSFiddle here: http://jsfiddle.net/lenoxDoe/n6Xbw/2/
您可以在这里检查我的JSFiddle: http : //jsfiddle.net/lenoxDoe/n6Xbw/2/
Any advice would be helpful. 任何意见将是有益的。
1. the hasMany property is an array
1. hasMany属性是一个数组
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.