0
votes

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

  1. define the alias when extending grid panel.
  2. traverse the DOM using this.up('alias') to get the grid panel.

Is it really the only solution? Thanks.

2

2 Answers

2
votes

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();
            }
        }
    ],
}
1
votes

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.