PDA

View Full Version : how to implement event handling on a tbr into a panel.



alberto01
7 Oct 2010, 10:11 AM
Hello,
I've got a problem.

I have a tbar inside a Panel (OK)

MyPanelUi = Ext.extend(Ext.Panel, {
title: 'My Panel',
width: 929,
height: 613,
initComponent: function() {

this.tbar = {
xtype: 'toolbar',
id: 'mainmenu',
items: [
{
id: 'avvisi',
xtype: 'button',
text: 'Avvisi (3)',
}, ....

And then the initialization of the class:

MyPanel = Ext.extend(MyPanelUi, {
initComponent: function() {
MyPanel.superclass.initComponent.call(this);
this.title = 'Changed OK'; ///this works fine
}


});


But now I need to assign to every button an action.
How can I extend the tbar from here?
I cannot understand how to have access to the tbar...

Thanks AL

alberto01
7 Oct 2010, 10:21 AM
Sorry I think I found the solution.


tbar = this.getTopToolbar();
tbar.getComponent('avvisi').text = 'Avvisi (34)';
tbar.getComponent('avvisi').handler = function(){
alert('Avvisi (34)');
};


Question: is this the right solution?

Thanks and sorry for the auto-solved question ...