//Global variable to hold the node that was last clicked var lastNode = null; // The client event ‘ItemClick’ takes two parameters sender and e // sender is the object which is raising the event // e is the DataMenuItemCancelEventArgs function WebDataMenu1_ItemClick(sender, e) { //Get the Key of the menu item that was clicked switch (e.getItem().get_key()) { case "EDIT": if (lastNode != null) { //Gets reference to the WebDataTree var tree = $find("WebDataTree1"); if (tree != null) { //Gets the nodeEditing object var nodeEditing = tree.getNodeEditing(); //Enters into node editing mode nodeEditing.enterNodeEditing(lastNode); } } break; case "ExpandCollapse": if (lastNode != null) //Changes the Expanded state of the node to the opposite value // from what it is currently. If the node is expanded, then it will be //collapsed. If the node is collapsed, it will be expanded. lastNode.toggle(true, true); break; } } // The client event ‘ValueChanging’ takes two parameters sender and e // sender is the object which is raising the event // e is the DataTreeNodeEventArgs function WebDataTree1_NodeClick(sender, e) { lastNode = e.getNode(); //Gets reference to the WebDataMenu var menu = $find("WebDataMenu1"); if (menu != null && e.get_browserEvent() != null && e.get_browserEvent().button == 2) //The showAt method takes three parameters x,y,browserEvent (optional). //x -- X axis position for absolute positioning of menu //y -- Y axis position for absolute positioning of menu //browserEvent -- auto positioning based on browser event menu.showAt(null, null, e.get_browserEvent()); }