繁体   English   中英

向ExtJS gridPanel按钮的处理程序添加多个功能

[英]adding multiple functions to an ExtJS gridPanel button's handler

我有一个带有触发全局函数的按钮的ExtJS gridPanel:

grid = Ext.create('Ext.grid.Panel', {
...
    tbar: [
        {
            xtype: 'button',
            text: 'Group',
            handler: group // call to global function
        }
    ]
...
});

在调用了group函数之后,我需要调用另一个全局函数,例如renameGroups 如何在处理程序中放置此函数或实际上任何其他函数?

我们在JavaScript中所做的通常是定义我们自己的函数来调用所有其他函数,因此在您的示例中:

grid = Ext.create('Ext.grid.Panel', {
...
tbar: [
    {
        xtype: 'button',
        text: 'Group',
        // will call the function when clicked, which will then call the others
        handler: function(e) {
            group(e); 
            renameGroups(e);
        }
    }
]
...
});

有几种不同的选择。

  1. 无需使用处理程序,您可以侦听来自其他组件的点击。 例如:

    grid.down('[text = Group]')。on('click',function(){});

  2. 您可以在网格中放置一个函数,然后直接从处理程序内部调用它:

    button.up( '网格')renameGroups();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM