Categories | Question details Back To List | ||
Context on an empty tree/grid 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. vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv context_menu = new dhtmlXMenuObject(null, "standard"); context_menu.setImagePath("js/dhtmlxMenu/imgs/"); context_menu.setIconsPath("js/dhtmlxMenu/imgs/"); context_menu.renderAsContextMenu(); context_menu.setOpenMode("web"); context_menu.setWebModeTimeout(300); context_menu.loadXML("projects_context_menu.xml"); ... project_grid = new dhtmlXGridObject('project_div'); ... project_grid.enableContextMenu(context_menu); ... project_grid.init(); project_grid.loadXML("load_projects.php"); ... <div id="project_div" style="width:980px; height:260px;"></div> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Answer posted by Support on Dec 02, 2008 04:20 The next command project_grid.enableContextMenu(context_menu); 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 Answer posted by MHW on Dec 02, 2008 05:32 I'm afraid I'm still unable to get it to work. I have both the following lines together in my code: project_grid.enableContextMenu(context_menu); context_menu.addContextZone('project_div'); They appear after the context_menu.loadXML("projects_context_menu.xml"); but before the project_grid.init(); and project_grid.loadXML("load_projects.php"); I have dhtmlxmenu v.2.0 build 81009 Answer posted by Support on Dec 02, 2008 09:30 Please try to use next code, which is more stable solution Answer posted by MHW on Dec 09, 2008 08:25 Thanks. That worked, however, it appears that the addContextZone might be conflicting with (or preventing the triggering of) the 'onBeforeContextMenu' event: context_menu.attachEvent("onBeforeContextMenu", ... 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. Thanks Answer posted by Support on Dec 09, 2008 10:03 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" context_menu.attach_event("onContextMenu",function(id){ //called nearly the same as onBeforeContextMenu event of grid, but will work for independent context zones as well }) |