Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Natalia Bazanova on Dec 17, 2008 05:02
open dhtmlx forum
Context Menus for 2 trees

I have 2 trees on the page and I want both of them to have a context menu, different menus. Is it possible?
Answer posted by Support on Dec 17, 2008 05:39
Sure, you can use dhtmlxMenu and 
   tree.enableContextMenu(menu_obj); 
to use menu as context menu of tree ( works in pro version only ) 

In case of standard edition of tree, you can use onRightClick event of tree, and call any kind of custom context menu from it. 
   
Answer posted by Natalia bazanova on Dec 17, 2008 05:51

Sorry, may be I wasn't clear. I declared 2 trees(dhtmlXTreeObject) and 2 context menus (dhtmlXMenuObject) and used enableContextMenu() method to attach

menu1 to tree1 and menue 2 to tree2. It doesn't work in my case. Is it supported?

Answer posted by Support on Dec 17, 2008 06:17
Please provide code snippet used in problematic case. 
There is no any restrictriction on count of components or context menus per page
Answer posted by Natalia Bazanova on Dec 17, 2008 06:25
I had no problems with only one tree having a context menu, everything was working perfectly well. The problem started when I added the second menu to the second tree. Thanks you.

menu = new dhtmlXMenuObject(null,"standard");
                menu.renderAsContextMenu();
                menu.setOpenMode("web");
                menu.attachEvent("onClick",onButtonClick);
                menu.loadXML("FAQ/xml/_tree_context.xml");

menu_list = new dhtmlXMenuObject(null,"standard");
                menu_list.renderAsContextMenu();
                menu_list.setOpenMode("web");
                menu_list.attachEvent("onClick",onButtonClick);
                menu_list.loadXML("FAQ/xml/_list_context.xml");

tree=new dhtmlXTreeObject('treeboxbox_tree',"100%","100%",0);
tree.enableContextMenu(menu);
tree.attachEvent("onBeforeContextMenu", showContextMenu);
tree.loadXMLString( transformedXMLTree );//load root level from xml


list=new dhtmlXTreeObject('doc_list',"100%","100%",0);            
list.enableMultiselection(true);
list.loadXMLString(transformedXMLList);//load root level from xml
Answer posted by Support on Dec 17, 2008 07:21
The problem can't be reconstructed with provided code - working sample sent by email
Answer posted by Natalia Bazanova on Dec 18, 2008 07:51
It's working fine, my mistake!