我试图在视图中获得父组件,但总是得到这个错误:
Cannot call method 'getParent' of undefined
代码如下:
initialize: function() {
this.callParent();
this.loadMates();
},
loadMates: function() {
var store = Ext.create('App.store.user.Mates');
store.getProxy().setExtraParam('userId', this.getParent().getUserId());
this.setStore(store);
}
我不知道为什么初始化的视图是undefined
。我尝试将"this"作为参数推送,但没有成功。
提前谢谢你。
编辑:
我在这里发现了一些东西:http://www.sencha.com/forum/showthread.php?174406-this.parent-and-this.getParent () -always-return-undefined-in-initialize
好了,我已经把所有的逻辑移到了Controller中。在refs
中有链接到父视图和实际视图。现在我可以很容易地访问父属性。加载函数在实际视图被推送后被调用