PDA

View Full Version : Event in sub menu of a Picker



medmathieu
17 Apr 2013, 11:10 AM
I want create a menu with item and sub menu in a trigger.

Menu and sub menu are created but sub items don't fired event.
I have the click event on the first menu level, but not on sub menu
Do you have an idea of my error?
I try with different methods, but no success.

Here the code:

Ext.define('MedComponent.task.command.field.MedCommandTextField' ,{
extend: 'Ext.form.field.Picker'
,alias : 'widget.medCommandTextField'

,trigger1Cls : Ext.baseCSSPrefix + 'form-command-trigger'
,onTrigger1Click : this.onTriggerClick

,createPicker: function() {

var picker = new Ext.menu.Menu({
items: [
{
text: 'Tag'
,menu:{
xtype: 'menu'
,items: [
{text: 'Item1' ,handler: function(){
console.log('toto');
this.addValue('%Tag_Item1%');
}
,scope: this
}
,{text: 'Item2', handler: onItemClick}
,{text: 'Item3', handler: function(){
console.log('click Item3');
}
}
,{text: 'Item4', handler: function(){
console.log("handler Item4");
}
}
,{text: 'Item5'}
]
}
,handler: function(){
console.log('handler');
}
}
,{
text: 'Association'
,menu:{
items: [
{text: 'Item6'}
]
}
}
]

});

return picker;
}


,addValue: function(iValue)
{
console.log('Add Value' + iValue);
this.setValue(this.getValue() + iValue);
}
});

function onItemClick(item){
console.log('onItemClick');
}


Thanks in advance

slemmon
18 Apr 2013, 9:48 PM
Perhaps add a click listener to each parent menu including the picker?
http://docs.sencha.com/extjs/4.2.0/#!/api/Ext.menu.Menu-event-click

PallaviS
27 May 2014, 1:43 AM
Even though the click event is added for the parent menu and the picker, click event is not being fired for the submenu items. Can you please help me.