PDA

View Full Version : Hanlder for Ext menu MVC



chichasonu
4 Dec 2015, 4:39 AM
Hi
I need to add Handler Event for Items Inside in Ext.menu.Menu
below is the Code Snippet
Menu Definition
Ext.define('MyAPP.view.northMenus',{
extend: 'Ext.menu.Menu',
alias:'widget.northMenu',
id:'northMenusId',




initComponent:function(){
//var me=this;
this.items=[{
text: '<b>'+'Regular Item 1',
id:'regularItem1',

itemid:'regularItem1'/* ,
action:'clickregularItem1' */
},{
text: '<b>'+'Regular Item 2',
id:'regularItem2',

itemid:'regularItem2'
},{
text: '<b>'+'Regular Item 3',

itemid:'regularItem3'
}],
this.layout='hbox';
this.floating=false;
this.callParent(arguments);


}

});
Controller Definition:
Ext.define('MyAppApp.controller.myAppController',{
extend: 'Ext.app.Controller',
views: ['northMenus','grid'],
models: ['users'],
stores: ['users'],

init: function(){
var me=this;

this.control({
'northMenusId menu[action=clickregularItem1]': {
'click': this.add
},
'northMenusId':{
'click': this.onItemClick

}

});

},
add: function(){
alert(1);
},
onItemClick:function(menuitem){
alert(2);
}
});

I am not getting these alerts.
Please help me
Thanks in Advance

jdkhamba
4 Dec 2015, 10:15 AM
Hard to say where exactly you are going wrong. Here is a working example:

https://fiddle.sencha.com/#fiddle/1241

chichasonu
5 Dec 2015, 12:11 AM
Thanks a Lot.Now in my view port i have north region and centre region.I need to add dynamic components based on menu click which is present in northe region.Can you please let me know how can I do That

jdkhamba
5 Dec 2015, 4:44 AM
Thanks a Lot.Now in my view port i have north region and centre region.I need to add dynamic components based on menu click which is present in northe region.Can you please let me know how can I do That

I thought we already discussed that here:

https://www.sencha.com/forum/showthread.php?307130-Adding-Dynamic-Components-for-From-Panel-With-Regions

S (https://www.sencha.com/forum/showthread.php?307130-Adding-Dynamic-Components-for-From-Panel-With-Regions)lightly modified example:

https://fiddle.sencha.com/#fiddle/124p

chichasonu
6 Dec 2015, 11:52 PM
HI
Thanks for the Reply
In My Center Region i need to add dynamic closabel tabs with grid/Formpanel inside the Tab.
Can you Please help me with the same.

chichasonu
7 Dec 2015, 2:27 AM
Ext.define('MyApp.view.myAppTabPanel',{
extend: 'Ext.tab.Panel',
alias:'widget.myAppTabPanel',
itemId:'MyAppTabPanel',
initComponent: function () {
this.items=[{xtype:'remoteGrid'}];
this.callParent(arguments);
}
});


I gave the above ref in my constructor


{
ref: 'myAppTabPanel',
selector: 'myAppTabPanel'
}
When i try to add item to Tab
this.getMyAppTabPanel().add
Throwing an error Saying add in not a function of undefined

Please Help
Thanks in Advance

chichasonu
7 Dec 2015, 7:06 AM
Hi,
I am able to add Dynamic Tabs on Menu Click in Center Region.
But upon Clicking On One menu I need to get only One Tab and Grid inside the Tab,Irrespective of the number of clicks on the Menu Button.
Can you please help me in achieving This.

Thanks in Advance

jdkhamba
7 Dec 2015, 7:10 AM
You could simply disable the menuitem after the first click so that only one item is added.

http://docs.sencha.com/extjs/4.2.0/#!/api/Ext.menu.Item-method-disable

chichasonu
7 Dec 2015, 8:22 AM
So,By this way,I need to enable the Menu Button Again After closing the Tab.
Right...?

jdkhamba
7 Dec 2015, 4:25 PM
That depends on what your business requirement is :-)

chichasonu
7 Dec 2015, 9:13 PM
Is their a way to achieve this by not disabling the menu..?

jdkhamba
8 Dec 2015, 5:33 AM
Yes there is. Before adding a tab to the tab panel, just check if the type of type that you are trying to add already exists or not. In other words, you need to uniquely identify each tab that was added to the tabpanel. If it exists, then don't add anything, just activate the correct tab usign setactivetab


http://docs.sencha.com/extjs/4.2.0/#!/api/Ext.tab.Panel-method-setActiveTab


This way you won't have to disable the menu items.

chichasonu
8 Dec 2015, 6:42 AM
Can you please Give me syntax for the same.

jdkhamba
8 Dec 2015, 9:34 AM
Sure
Take a look:

https://fiddle.sencha.com/#fiddle/128n

chichasonu
8 Dec 2015, 6:59 PM
Thanks a Ton...:)