PDA

View Full Version : Controller action painted not firing but works on component listener



mark.tvi
14 May 2012, 3:05 AM
Hi, I have a list component inside a navigation view and on the itemtap event it instantiates a new custom panel and adds it to the navigation view. I've created a controller action on the custom panel's painted event. This doesn't fire at all even though I know the component query is correct. If I add a listener to the painted event directly on the custom panel is fires correctly every time.

Am I doing something wrong?


Ext.define('My.controller.CustomController', {
extend: 'Ext.app.Controller',
config: {
control: {
"customList": {
itemtap: 'onCustomListItemTap'
},
"customPanel": {
painted: 'onCustomPanelPainted'
}
}
},


onCustomListItemTap: function(dataview, index, target, record, e, options) {


dataview.up('navigationview').push(Ext.create('My.view.CustomPanel', {


title: record.data.firstName + ' ' + record.data.lastName,
data: {
ID: record.data.ID
}


}));


},


onPanelPainted: function(component, options) {


console.log('painted event fired');



}


});

mitchellsimoens
16 May 2012, 5:12 AM
The painted and erase events aren't listenable in the controller for performance reasons.

mark.tvi
18 May 2012, 5:29 AM
Thanks for the reply. I was to understand that controller actions should be used to handle everything in my app. I'm not sure it's documented that the painted event can't be handled here. This event is the most useful to know when a component is in view so I'll have to go back to using good old component events.

alank
15 Jul 2014, 6:06 AM
I agree this should be documented better.

If you want to listen for the event in the controller you can fire it manually...


listeners: {
painted: function() {
this.fireEvent('painted', this);
}
}