PDA

View Full Version : Controller and generated getter for view access



börn
1 Dec 2011, 11:48 PM
I want to access a view inside a controller function and want to use the generated getter. Unfortunately the getter returns only a function (i think the constructor function)? When using refs the generated getter works... why not the other ones? Here is some example code (any suggestion? is the afterrender event to early for the controller?):


Ext.define('App.controller.MyController', {
extend: 'Ext.app.Controller',


refs: [
{
ref: 'drawPanel',
selector: 'drawPanel' //name of the widget
}
],


views: [
'xxx.DrawPanel' //refering to app/views/xxx/DrawPanel.js
],

//stores and models


init: function()
{
this.control(
{
'drawPanel': {
afterrender: this.addSprite
}
});
},


addSprite: function()
{
var drawPanel = this.getDrawPanel(); //works... but
//var drawPanel = this.getXXXDrawPanelView() //not!
//var s = drawPanel.canvas.surface...
}
});

redraid
2 Dec 2011, 12:44 AM
Controller generate getters for models and stores not for views, views getters generated from refs config.

börn
2 Dec 2011, 1:14 AM
ah okay... but why do I have those getters in the controller? Are they meant to be factory methods?