PDA

View Full Version : Ext Js 4.1 Right Click Menu



mandardadpe
29 Oct 2012, 10:57 PM
I have few menus(copy,paste,add) on right click of tree node and on left click it loads tree grid in tab panel.
But problem is ,when I right click on a node it also send ajax request to database.So, I want it functions either or. It should not send AJAX agian on right click. My code for right click is as follows:

ProjecttreePanel.on('itemcontextmenu', function(view, record,HTMLTarget , index, event){
x = event.browserEvent.clientX;
y = event.browserEvent.clientY;
menu1.showAt([x, y]);
event.stopEvent();
menu1.record = record;
menu1.HTMLTarget = HTMLTarget;
menu1.showAt(event.getXY());
event.preventDefault();
event.stopEvent();
},this);

Thanking You in advance,
-Mandar Dadpe

James Goddard
30 Oct 2012, 5:05 AM
Probably what is happening here is you are using the 'itemclick' event for your load and the 'itemcontextmenu' for your menu.

The 'itemcontextmenu' is bound to right click but you are probably getting 'itemclick' for any type of click. You'll need to inspect the raw event (the e parameter) in your itemclick handler to ignore right clicks.

mandardadpe
31 Oct 2012, 3:22 AM
I am using itemcontextmenu and I want to ignore left click when I right click for menu.Is there anything like event.preventdefalult();..

James Goddard
31 Oct 2012, 3:40 AM
"Loading a tree grid in a tab panel" is not "default" behavior. It is something you are doing. As isaid before, where you are doing that check the event to see which button was clicked.

mandardadpe
31 Oct 2012, 3:52 AM
I am not checking anyhing. I have tree panel ,on its node click (i.e Left click) certain actions are performing. But on right click on tree panel node , menu list appears. So,at the moment of right click actions which are supposed to be performed on left click should not perform.

James Goddard
31 Oct 2012, 4:17 AM
I am not checking anyhing.

That's the problem. Please post the code that handles the "left" click and loads the tree grid in the tab panel.

mandardadpe
31 Oct 2012, 4:38 AM
ProjecttreePanel.getSelectionModel().on('select',function(selModel, record)
{
if (record.get('leaf')||!record.get('root')) {
Code written
}
}
Above code I have written for left mouse click.

James Goddard
31 Oct 2012, 4:56 AM
ProjecttreePanel.on ('itemclick', function (grid, record, item, index, e, eOpts) {
if (1 == e.browserEvent.which && record.get ('leaf') || !record.get ('root')) {
Code written
}
});


Select doesn't pass the browser event so use click instead to test.

mandardadpe
31 Oct 2012, 5:52 AM
If I use '
itemclick' instead of select, it doesnt perform anything. Means on click of tree node I am enabling tab panels and few buttons. "itemclick" might not be an option