My tree code
//tree layout
dhxLayout.cells("a").setText("Server");
dhxLayout.cells("a").setWidth(250);
dhxLayout.cells("a").hideArrow();
dhxTree = dhxLayout.cells("a").attachTree();
dhxTree.setImagePath("imgs/icon/tree/");
dhxTree.setXMLAutoLoading("xml/tree_serverlist.php");
dhxTree.enableHighlighting(true);
dhxTree.enableKeyboardNavigation(true);
dhxTree.enableContextMenu(Contextmenu);
dhxTree.loadXML("xml/tree_serverlist.php");
dhxTree.attachEvent("onClick",function(id)
{
showDirContent(id);
});
dhxTree.attachEvent("onBeforeContextMenu", function(itemId)
{
//alert(itemId);
if(itemId=="server_top")
{
Contextmenu.showItem('add_server');
Contextmenu.hideItem('connect_server');
Contextmenu.hideItem('edit_server');
Contextmenu.hideItem('view_server');
Contextmenu.hideItem('delete_server');
Contextmenu.hideItem('file_sep_2');
Contextmenu.hideItem('file_sep_1');
Contextmenu.hideItem('disconnect_server');
}
else
{
Contextmenu.hideItem('add_server');
Contextmenu.showItem('connect_server');
Contextmenu.showItem('file_sep_1');
Contextmenu.showItem('edit_server');
Contextmenu.showItem('view_server');
Contextmenu.showItem('delete_server');
Contextmenu.showItem('file_sep_2');
Contextmenu.hideItem('disconnect_server');
}
return true;
});
//end
This is my tree code. I used the hide/show method to load my context menu. But as the system grows, i want the context menu load according to my tree id
My context menu
//tree context menu
Contextmenu = new dhtmlXMenuObject();
Contextmenu.setIconsPath("imgs/icon/");
Contextmenu.renderAsContextMenu();
Contextmenu.attachEvent("onClick", onContextMenuClick);
Contextmenu.loadXML("xml/context_menu.php");
//end
and my xml file
<?php
header('Content-type: application/xml');
include $_SERVER['DOCUMENT_ROOT']."My_Phanto/class/server_class.php";
include $_SERVER['DOCUMENT_ROOT']."My_Phanto/class/web_service.php";
include $_SERVER['DOCUMENT_ROOT']."My_Phanto/class/connect.php";
$id=$_REQUEST[id];
//$id is the tree id.
?>
<menu id="0">
<item text="Add Server" img="add.png" id="add_server"/>
<item text="Connect Server" img="connect.png" id="connect_server"/>
<item text="Disconnect Server" img="disconnect.png" id="disconnect_server"/>
<item id="file_sep_1" type="separator"/>
<item text="Edit Server Information" img="edit.png" id="edit_server"/>
<item text="View Server Information" img="view.png" id="view_server"/>
<item id="file_sep_2" type="separator"/>
<item text="Delete Server" img="delete.png" id="delete_server"/>
</menu>
Is there anyway to load my context menu according to my tree id?
Please help me…Thanks.