Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Brian O'Connor on Jul 16, 2009 10:15
open dhtmlx forum
dhtmlXTree v2.1 Pro. and dhtmlXMenuObject context menu appears at bottom of containing page

dhtmlXTree v2.1 Pro. and dhtmlXMenuObject context menu appears at bottom of containing page

My company has recently purchased a Profession license for DhtmlXTree. I am trying to use the Context Menu within the Tree bu the Menu only appears at the bottom of the page rather than near the tree item that was actually clicked. I have tried the position:relative style change mentioned on this site but without success. Can you tell me how I can correct this behaviour.


My html code is as follows (must work in IE 6 and 7 Browsers) ..


<div id="treebox_previewRa_Tree_Div" style="height:240px; width:100%; align:left; z-index:0; position:relative;">
 <table>
  <tr>
   <td valign="top" style="width:100%;">
    <div id="treebox_previewRa_Tree" style="width:97%;height:218px;background-color:#f5f5f5;border :1px solid Silver;; overflow:auto;"/>
   </td>
  </tr>
 </table>
</div>


My JS code is as follows ..

function showTree(requiredUrl) {

   var menuUrl = "assessmentPreviewTreeMenu.xml";
   menu = new dhtmlXMenuObject(null, "standard");
   menu.setImagePath("scripts/dhtmlx_v2.1/dhtmlxMenu/codebase/imgs/");
   menu.setIconsPath("scripts/dhtmlx_v2.1/dhtmlxMenu/codebase/imgs/");
   menu.renderAsContextMenu();
   menu.setOpenMode("web");
   menu.attachEvent("onClick", onMenuItemClick);
   menu.loadXML(menuUrl);


   previewRa_Tree = new dhtmlXTreeObject("treebox_previewRa_Tree","100%","100%",0);
   previewRa_Tree.setImagePath("scripts/dhtmlx_v2.1/dhtmlxTree/codebase/imgs/");
   previewRa_Tree.setOnDblClickHandler(doOnDblClick);
   previewRa_Tree.attachEvent("onXLE", sortPreviewTree);
   previewRa_Tree.enableCheckBoxes(1);
   previewRa_Tree.enableContextMenu(menu);
   previewRa_Tree.loadXML(requiredUrl);
}


function beforeContextMenuShows(itemId) {
   var id = previewRa_Tree.contextID;
   menu.hideItem('edit-issue');
   menu.hideItem('new-issue' );
   return true;
}

function onMenuItemClick(menuitemId,type){
   var id = previewRa_Tree.contextID;
   alert("You clicked Tree Item id = " + id);
}

Answer posted by Alex (support) on Jul 17, 2009 01:35

Hello, 

the issue wasn't reproduced locally. Could you please provide the complete demo to support@dhtmlx.com

Answer posted by Brain O'Connor on Jul 17, 2009 03:22

Hi Alex, thanks for coming back so quickly. Thankfully I managed to find the solution after I contacted you yesterday.

I had to change the following line ..

menu = new dhtmlXMenuObject(null, "standard");   .. to ..
menu = new dhtmlXMenuObject(null, "dhx_blue");

The Tree context menu is now working as expected. Wonderful product by the way!

Many thanks,

Brian