PDA

View Full Version : context menu on form ?



Vikram
31 Jul 2013, 7:06 AM
how can i display below context menu on right click on the form ?
Actaully i have a grid i want to show and hide with the help of context menu,
how can i achieve this ?


var contextMenu = new Ext.menu.Menu({
items: [{

text: 'Hide',
iconCls: 'hide'
}, {
text: 'Show',
iconCls: 'show'
}]

});
contextMenu.show();



Thanks
Vik

Gary Schlosberg
2 Aug 2013, 6:37 PM
Going out of order, to hide and show your grid, you will need to attach 'click' listeners on each item in the context menu which use hide() and show() on your grid:



listeners : {
click : function() {
grid.hide();
}
}


The right click is handled by the 'contextmenu' event as you probably know, but form panels do not have that event to configure. Perhaps the following will prove useful:



form.el.on('contextmenu', function(evt, div) {
evt.preventDefault();
contextMenu.show()
})


This old thread might be helpful too:
http://www.sencha.com/forum/showthread.php?40244