I’m trying to get my context menu to work when the tree/grid is empty. I’ve tried to copy some of the responses to similar knowledgebase questions but have been unsuccessful. Hope you can point me in the right direction. Thanks.
context_menu = new dhtmlXMenuObject(null, “standard”);
project_grid = new dhtmlXGridObject(‘project_div’);
The next command
enables context menu support for rows in grid.
If you need to have it for empty space as well, you can add one more row
context_menu.addContextZone(‘project_div’); //for dhtmlxmenu 2.x
I’m afraid I’m still unable to get it to work.
I have both the following lines together in my code:
They appear after the
but before the
I have dhtmlxmenu v.2.0 build 81009
Please try to use next code, which is more stable solution
Working sample sent by email
Thanks. That worked, however, it appears that the addContextZone might be conflicting with (or preventing the triggering of) the ‘onBeforeContextMenu’ event:
Is there a workaround? I’m using the ‘onBeforeContextMenu’ event to show/hide menu items, depending on the object the right-clicked is triggered from.
onBeforeContextMenu generated only for cases when menu initialized by grid. In above case , the context menu use independent context call handler , so no event generated.
You can try to use event of menu - "onContextMenu"
//called nearly the same as onBeforeContextMenu event of grid, but will work for independent context zones as well