I am using WebMenu as a contextmenu for ultrawebgrid cells. The contextmenu works fine if I place the webgrid and webmenu directly in the page. The problem starts when I am trying to create a usercontrol using webgrid and webmenu, contextmenuclick(right click on grid cell) gives me an error saying "Popup name not valid".
igmenu_showMenu("<%=this.MROContextMenu.ClientID %>",null,0,0);
Thanks
Hello,
You can use the client-side InitializeMenu event of UltraWebMenu to find out the ID of the menu, and later use it to show the context menu. I did a quick search in our forum archives and found out that a customer has reported a problem very similar to yours (same error message while trying to show context menu for grid or treeview) and as the discussion goes on, it appears that the InitializeMenu approach resolved the problem.
Link (I am using tinyurl since the link is very long and gets corrupted in the HTML editor Community Server is using):
http://tinyurl.com/yu2qjd
I hope this helps. Please, let me know if this is not working / not applicable in your setup.
Thank you very much for that pointer. I have tried using the InitializeMenu event and got the menu id. Now that error has gone but I am not able to see the menu. No error and no context menu. Strange thing!!! any ideas??
The code now is :
<MenuClientSideEvents ItemClick="ContextMenuItemClick" InitializeMenu="InitializeLayout" />
In BLOCKED SCRIPT
{
MyMenuId = menuId;
alert(MyMenuId);
}
igmenu_showMenu(MyMenuId,null,0,0);
Thanks.
Thanks for the follow-up. Is the alert showing the correct client-side ID?
In any case, I believe the key here could be the parameters to the igmenu_showMenu method. I've found out several test project demonstrating this live in action, and they always required a valid "event" (the second parameter), plus some coordinates - x,y (third and fourth parameters).
You can find the following KB article useful:
HOWTO:How to show and hide the UltraWebMenu when used as a context menu
http://devcenter.infragistics.com/Support/KnowledgeBaseArticle.Aspx?ArticleID=10083
It demonstrates sample code/approach, plus there a couple of projects attached to it where you can see this live in action.
Its rendering the menuid as "MROGridControlMROContextMenu" i.e., parentcontrolid+contextmenuid.
I have avoided the event parameter as I have read that event is understood only by IE not other browsers and I am targeting IE and Firefox browsers.
To be sure if event param is causing the problem, I have tested the code passing the event parameter but it still didnot work. Not sure why !!
Take a look at the Excel Copy & Paste sample in the samples browser. I spent a good day banging my head against the wall trying to figure out how to get a context menu positioned correctly cross browser, so I definitely feel your pain. As much as I understand why firefox doesn't have a global "event" object, it sure makes things hard :) The key is to pass the "event" parameter into the function as a parmeter. Firefox will always use the first parameter in an event handler as the event object.
Then you can calculate the position using the event object. A warning though - calculating positions cross browser is another headache. Lastly, you want to be sure to call igmenu_showMenu as you're doing above (menuid, null, x,y). I remember running into an issue with quotations not being correctly placed around my ID under some odd configuration, so you'll want to do a quick views source on your HTML page to be sure that <%= ...%> is actually rendering out what you think it should.
hth,
-Tony
Thanks for your time and suggestions. I have gone through the Excel Copy paste sample before and infact that sample is the base for my grid.
I had a work around for my problem of contextmenu. I was struggling to create a usercontrol consisting webgrid and webmenu and it didnot work because of problem with MenuID. So I seperated them out. I have put the webgrid in the usercontrol and webmenu in the aspx page and ran the same scripts and it worked.
Now the only issue which remains is what you have mentioned "positioning the contextmenu". If I pass 0,0 as x,y then the menu is showing fine for some inner column cells but going out of screen for cells which are in the last column. Can I have the codebit of what you are talking abt passing event object, calculating the position so that it will work for firefox also?
Hello!
I have the same problem. When i put the webmenu in the aspx-page it works fine. Now i wanted to move them in a user control. First it ran fine at my computer, as well as at one hosting system. At the other hosting system the webmenu doesn't work anymore. I get the menu, but i can't click on the items to get the submenus and i get the error that the igMenu_ // _events is not defined. Any ideas what i can do to run the webmenu in a user control?
Thanks, Martin.
Thanks a lot for helping.
The strange thing is, that once it worked, without a changing anything. I really have no clue why, but anyway.
What I ended up doing was to declare variables for the grid and menu, and then assign the values to them on their load events, like this. I pieced this together from a few different examples I had seen for different issues. Hope it helps.
Mike
var MyMenuId; var MyGridId; function uwgListsEntered_InitializeLayoutHandler(gridName){ // because we have the grid within a masterpage and within the content placeholder we have to capture the // name of the grid when it is initialized, otherwise the name has the contentplaceholder as it's prefix. MyGridId = gridName;} function InitializeLayout(menuId) { MyMenuId = menuId; }
May be some code on how u r calling the menu would help.