Sample: dhtmlxTree Context menu based on item properties dhtmlxTree main page
X

Right click on tree node.
In example below context menu is one for all items, but it is shown differently by using hideButtons/showButtons menu methods (items without children have more buttons in context menu).


 
<div id="treeboxbox_tree" style="width:200;height:200"></div>
<script>
 
    //change menu items depending on tree node
    function ChangeMenu(itemId){
         if (tree.hasChildren(itemId) > 0){
             aMenu.menu.hideButtons('outher');
         } else {
             aMenu.menu.showButtons('outher');                
         }
         //tree.selectItem(itemId,true);
     }
    //init menu
            aMenu=new dhtmlXContextMenuObject('120',0,"../../../dhtmlxMenu/codebase/imgs/");
            aMenu.menu.loadXML("menu/_context.xml");                
            aMenu.setContextMenuHandler(onButtonClick);
            aMenu.setOnShowMenuHandler(ChangeMenu)
    //init tree    
            tree=new dhtmlXTreeObject("treeboxbox_tree","100%","100%",0);
            tree.setImagePath("../imgs/");
            tree.enableDragAndDrop(true);            
            tree.enableContextMenu(aMenu); //link context menu to tree
            tree.loadXML("tree.xml")
</script>


THIS PAGE CONTAINS SAMPLE FUNCTIONALITY OF PROFESSIONAL EDITION FOR DEMONSTRATION PURPOSE ONLY.
UNAUTHORIZED USE IS PROHIBITED. PLEASE CONTACT SALES@DHTMLX.COM TO OBTAIN A LEGAL COPY OF PROFESSIONAL EDITION.