0
필자는 ExtJS에서 연관성을 지닌 가장 간단한 모델을 구축했다.연결이있는 간단한 ExtJS 데이터 예제가 작동하지 않는 이유는 무엇입니까?
모델 : 포스트-hasOne의 ->사용자
내가 무슨 짓을 :
- 규칙에 따라 메모리 프록시
- 사용 : 프록시 모델 에
- 게시 개체를
Post.load(...)
까지로드하십시오.
나는 사용자 개체를 얻을 때, 그것은 잘로드되지 않습니다 :
(여기에 전체 소스 : http://jsfiddle.net/7XRw4/4/)
Ext.define('Post', {
extend: 'Ext.data.Model',
fields: ['user_id', 'content'],
hasOne: 'User',
proxy: {
type: 'memory',
data: {
posts: [
{id:1, user_id:1, content:'foo'},
{id:2, user_id:1, content:'bar'}
]
},
reader: {
type: 'json',
root: 'posts'
}
}
});
Ext.define('User', {
extend: 'Ext.data.Model',
fields: ['name'],
proxy: {
type: 'memory',
data: {
users: [
{id:1, name:'hans'},
{id:2, name:'klaus'}
]
},
reader: {
type: 'json',
root: 'users'
}
}
});
Ext.onReady(function() {
console.log("Ext.onReady() invoked...");
Post.load('1', {
success: function(record, operation) {
thePost = record;
console.log('thePost:', thePost);
theUser = thePost.getUser();
console.log('theUser:', theUser);
alert('The user name: ' + theUser.get('name'));
// The user object will not be right loaded! Why?
}
});
});