PDA

View Full Version : context menu and renderTo



flamant
11 Nov 2010, 6:06 AM
Hi,
I implement a context menu on an element this way :



var elt = field.getEl();
elt.field = field;
elt.rowId = rowId
elt.on('contextmenu', function(evt, elRef) {
evt.stopEvent();
var field = this.field;
if (!this.ctxMenu) {
this.ctxMenu = new Ext.menu.Menu({
id: 'ctxMenu_'+field.getId(),
items: [...]
})
}
this.ctxMenu.showAt([evt.getPageX(), evt.getPageY()]);
}


field is to be a child of the following container container = Ext.getCmp('gridPanel_'+sptNbr+'_'+gridNbr)

When I inspect the page with firebug, I can see that the context menu's DOM element is outside the container's DOM element

I tried to put in my context menu : renderTo: Ext.getCmp('gridPanel_'+sptNbr+'_'+gridNbr).getEl().id, but the context menu show at somewhere else on the page and not anymore at the field's place.

My first question is : am I allowed to add renderTo to the context menu knowing that field is to be a child of container

My second question is : How can I ensure my context menu to be a child of container