PDA

View Full Version : Ext.menu.Menu() : How to get the width of the menu (needed to display it with offset)



daniel_r
20 Oct 2011, 2:45 PM
Hi, have asked same Q' on stack overflow but got no answers, hope to get more lucky in here :)

I built a context menu using Ext.menu.Menu() and populated it with items like this:



menu.addMenuItem({
text : TaskGeneralBaseds[i].getAttribute("Name"),
templateTypeID : templateTypeID,
taskType : taskType,
scope : this,
listeners : {
click : {
fn : this.extAddTaskClicked
}
},
icon:g ? g : null
});

and than i display the menu like this



var left = window.event.clientX;
var top = window.event.clientY;
menu.showAt([left,top]);


now the thing is that i want to display it with offset as if it was displayed from right to left and not from left to right (I already took care of all the other RTL issues) so if i had the width of the menu i could do something like this:



var menuWidth = menu.width;// how can i really get the width?
var left = window.event.clientX-menuWidth ;

var top = window.event.clientY;

menu.showAt([left,top]);



Any ideas?
Thanks ahead!
Daniel.