簡體   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