show context menu for empty grid (menu 2.0)

hi,



i have a slight problem regarding context menu and grid with the latest components. I want to show the context menu on a grid(area) even though there is no rows in the grid. This used to work in rel2 componets by creating a context menu with the grid container.



But the following code doesnot work anymore for rel3, it doesnot show the grid data anymore, but i do see the context menu when i right click. Looks like the context menu is overlaying the grid?

is that a bug?



Here’s the code:



contextmenu = new dhtmlXMenuObject(grid.entBox.id);

contextmenu.setImagePath(_imagePath);

contextmenu.renderAsContextMenu();

//contextmenu.setOpenMode(“web”);

//contextmenu.attachEvent(“onClick”,onButtonClick);

contextmenu.loadXML(“context.xml”);

grid.enableContextMenu(contextmenu);

The issue can’t be reconstructed locally. The context menu must not affect the rendering of data in grid.
Most probably problem caused by some specific of grid’s initialization.

If issue still occurs for you - please provide any kind of sample where issue can be reconstructed. ( you can send it directly to support@dhtmlx.com )

heres the sample code to reproduce the bug.


im using the rel3 dated OCTOBER (full dhtmlx.js pro version)



thanks,



test.html.zip (713 Bytes)
grid.xml.zip (718 Bytes)

In used code , replace
contextmenu = new dhtmlXMenuObject(grid.entBox.id);
with
contextmenu = new dhtmlXMenuObject();
it will resolve issue.

PLZ review my initial question!!!

i want to have a context menu appear even though the GRID IS EMPTY!

i know very well that using "contextmenu = new dhtmlXMenuObject();  " won’t cause the issue but that wasn;'t the point.
By doing so, no context menu will appear if the grid is empty or in the empty sections of the grid!

how do we fix this bug? i need to get the container of the grid…how to i retrieve it since it is encapsulated by the layout?

When you are using
contextmenu = new dhtmlXMenuObject(grid.entBox.id);
you are creating menu in same container , where grid was already created, which effectively destroys grid.

If you need to have menu for the empty grid, just use
contextmenu = new dhtmlXMenuObject();

menu.addContextZone(grid.entBox.id);

thanks !

that worked