2014-02-13 21 views
0

我有一個ExtJS的GridPanel與觸發全局功能的按鈕:添加多種功能於一個ExtJS的GridPanel按鈕的處理程序

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

我已經叫group功能後,我需要調用另一個全局函數,實例renameGroups;我如何在處理程序中放置這個函數或者其他的函數?

回答

1

我們在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); 
     } 
    } 
] 
... 
}); 
+0

感謝您的答案,與相關的代碼示例,這是很容易遵循和理解。 –

0

有幾個不同的選擇。

  1. 而不是使用處理程序,您可以偵聽從另一個組件的點擊。例如:

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

  2. 你可以把一個函數在網格中,並直接從處理程序內調用它:

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