PDA

View Full Version : How te get data from DB with toolbar?



marxan
18 Jun 2012, 6:07 AM
Hello,

I'm trying to create a menu by using the toolbar menu but in the example, the data are filled with the 'text' option. I would like to make it work with data from my DB as I won't need to come back in the code if a new option should appear.

My second question is a bit more complex, I don't know how to interact with another part of my screen when I click on the selected item. I've tried to create a Handler with a simple alert but nothing happened.


Ext.define('TAB.view.MainBorder', { extend: 'Ext.panel.Panel',
alias:'widget.mainborder',
layout: 'fit',
initComponent: function() {
var me = this;
Ext.applyIf(me,{


items: [
{ xtype: 'panel',
dockedItems: [{
dock: 'top',
xtype: 'toolbar',
height: 40,
xtype: 'button',
text: 'Choose indicator group',
menu: {
plain: true,
showSeparator: false,
items: [{
text: 'menu item one',
scope: this,
handler: this.onAddClick
},
{
text: 'menu item two'
},
{
text: 'menu item three'
}]
},

onAddClick: function(){
alert('test');
}




}]
}
],

//
})
me.callParent(arguments);
}



});


Thanks in advanced for any help.

Regards,

sdt6585
18 Jun 2012, 9:00 AM
I think your scope for the event handling function is wrong, try this:



Ext.define('TAB.view.MainBorder', { extend: 'Ext.panel.Panel',
alias:'widget.mainborder',
layout: 'fit',
onAddClick: function(){
alert('test');
},
initComponent: function() {
var me = this;
Ext.applyIf(me,{
items: [{
xtype: 'panel',
dockedItems: [{
dock: 'top',
xtype: 'toolbar',
height: 40,
xtype: 'button',
text: 'Choose indicator group',
menu: {
plain: true,
showSeparator: false,
items: [
{
text: 'menu item one',
scope: this,
handler: this.onAddClick
},
{
text: 'menu item two'
},
{
text: 'menu item three'
}
]
}
}]
}]
});


me.callParent(arguments);
}
});

scottmartin
18 Jun 2012, 9:19 AM
You may want to have a look at this:
http://www.sencha.com/forum/showthread.php?132422

Scott.

marxan
20 Jun 2012, 5:19 AM
Thanks, it works.