Hi,
I have a requirement: Do not show 2 options on the context menu if the tree item selected is the root (the first node in the tree).How can this be achieved?
I have tried many approaches but it does not work. One such approach is shown below:
tree.attachEvent(“onClick”,function(){
if (tree.getSelectedItemId() != “HO”) {
cMenu.menu.hideItem(“deleteRU”);
cMenu.menu.hideItem(“renameRU”);
}
return true;
});
tree.attachEvent(“onRightClick”,function(){
if (tree.getSelectedItemId() != “HO”) {
cMenu.menu.hideItem(“deleteRU”);
cMenu.menu.hideItem(“renameRU”);
}
return true;
});
Please suggest if there is a way to achieve this requirement
The code which you are using is correct, but you must not use getSelectedItemId - in moment of right click event , item in question is not selected yet. Instead of it you can use parameter of event.
tree.attachEvent(“onRightClick”,function(id){
cMenu.menu.showItems(); //to restore previously hidden items
if (id!= “HO”) {
cMenu.menu.hideItem(“deleteRU”);
cMenu.menu.hideItem(“renameRU”);
}
return true;
});