Reputation: 33
I got exactly the same problem as http://www.sencha.com/forum/showthread.php?140992-Ext.define-and-the-Scope and unfortunately there's no clear answer on the thread.
I know that scope:this
won't work since it will only change the scope from the button to the window, and based on my search and the suggestion given on the thread, I conclude that the only solution is
this.up('alias')
to get the grid panel.Is it really the only solution? Thanks.
Upvotes: 0
Views: 2002
Reputation: 182
based on the example from the post, try this...
initComponent: function() {
...
var me = this;
me.tbar = [
{
text: 'Start',
iconCls: 'icon-start'
}, {
text: 'Stop',
iconCls: 'icon-stop'
}, {
text: 'Eintrag hinzufügen',
iconCls: 'icon-add',
scope: me,
handler: function() {
me.addEntry();
}
}
],
}
Upvotes: 2
Reputation: 5488
Yes. The scope in handlers in components are usually the instantiated component of which's handler was called. That button in the tbar is actually a component, and its instantiated form becomes the scope. You should traverse to your Panel like you said to get the object you want.
Upvotes: 1