Extjs 5 引用网格通过停靠按钮的单击事件而不使用 .up?



我当前有一个带有一个按钮的网格,我单击该按钮,以对网格中的记录作用。目前,我使用button.up('selector');获取网格,但感觉有些骇人听闻。我认为也许通过将点击事件选择器更改为grid [action=buttonAction],而不仅仅是[action=buttonAction]可能会给我网格的上下文,但事实并非如此。是否有任何更清洁的方法来引用网格而不是button.up

var dockedItems = new Ext.toolbar.Toolbar({
                    items: {
        text: 'Do a thing',
        action: 'actionForTheThing'
    }
            });
 Ext.grid.Panel({
                store: this.store,
                dockedItems: dockedItems,
 });

然后在Ext.app.Controller控制器中定义处理程序

        this.control({
        '[action=actionForTheThing]': {
            click: this.handleTheThing
        },
       handleTheThing: function(button, click){
          //Here I have the button, but I want to get to the grid that has the button
          // Right now I can do button.up(''), but I want more of a strict relationship
          //like button.getParent(); or something.
       };

不,没有。

单击按钮的单击事件总是用按钮作为第一个参数触发,并且要更改该按钮,您必须在按钮上创建一个覆盖,覆盖fireHandler方法,其中click事件被触发:

me.fireEvent('click', me, e)

http://docs.sencha.com/extjs/6.2.1/classic/src/src/button.js.html#line1643

最新更新