Adding Context Menu support to a standard Table Cell
March 10th, 2010Here is the code that I am trying to use.
var menu = new Ext.menu.Menu({
id: 'mainMenu',
items: [
{
text: 'Menu 1',
checkHandler: onMenuClick
},
{
text: 'Menu 2',
checkHandler: onMenuClick
},
{
text: 'Menu 3',
checkHandler: onMenuClick
}]});
var ls = new Ext.util.on('contextmenu',show_menu,'mytest');
function onMenuClick() {
alert("Click");
}
| Cell |
Show us your code, and describe how it's going wrong and we'll be able to put you on the right track.
"new Ext.util.on" is almost random!
I changed the code to the following...
function show_menu() {
var menu = new Ext.menu.Menu({
id: 'mainMenu',
items: [
{
text: 'Menu 1',
handler: onMenuClick
},
{
text: 'Menu 2',
handler: onMenuClick
},
{
text: 'Menu 3',
handler: onMenuClick
}]});
menu.show('mytest');
return false;
}
var ls = Ext.get('mytest');
ls.on('contextmenu',show_menu,this,{preventDefault : true});
function onMenuClick() {
alert("Click");
}
and it works without a hitch. Thanks again for pointing me in the right direction. I have to say I really to like the approach you all take on here. You follow the "Give the man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime" approach. I learned a lot more than if someone had just given me the code.
#If you have any other info about this subject , Please add it free.# |