I have an Accordion screen with in each accordion item a tree menu. The tree items are loaded from a xml file. The onclick handler is working fine for menuItem2 but when I click in the tree of menuItem1 nothing happens. I also tested it via a confirm window (confirm(“you clicked node “+myTree.getSelectedItemId()+”?”); )to show the id but the id’s from the menuItem1 are not shown.
Here the script I’m using:
<script src="classes/dhtmlx/dhtmlx.js"></script>
<script>
var myAcc, myTree;
function doOnLoad() {
myAcc = new dhtmlXAccordion({
parent: "accObj",
items: [
{id: "menuItem1", text: "WMS"},
{id: "menuItem2", text: "Administratie"}
]
});
myTree = myAcc.cells("menuItem1").attachTree();
myTree.setImagePath("classes/dhtmlx/imgs/dhxtree_skyblue/");
myTree.loadXML("classes/dhtmlx/wms.xml");
myTree.setOnClickHandler(DoOnclick);
myTree = myAcc.cells("menuItem2").attachTree();
myTree.setImagePath("classes/dhtmlx/imgs/dhxtree_skyblue/");
myTree.loadXML("classes/dhtmlx/admin.xml");
myTree.setOnClickHandler(DoOnclick);
function DoOnclick(id){
switch(myTree.getSelectedItemId()){
case 'adm_users' : window.open("frmUserMaintenance.php", "appscreen");
break;
case 'wms_article': window.open("frmArtikel.php", "appscreen");
break;
}
};
}
</script>
The xml’s I’m using:
wms.xml:
<?xml version='1.0' encoding='iso-8859-1'?> and admin.xml: <?xml version='1.0' encoding='iso-8859-1'?> Can anyone tell me what I'm doing wrong. I'm a new user of dhtmlX and already enthusiast about it. The only strange thing I found is that in both xml files the tree id="0". If I change this the tree is not working anymore.