Hi there, I have a radtreeview which has a context menu which works perfectly on right click. When a user right clicks on a node in the tree the context menu will appear with options such as "delete [course name]", "edit [course name]", and "add [course name]". Where [course name] is is where the name of the node they are clicking on will go which also works perfectly. My tree view is like this:
ALL COURSES [ROOT]
COURSE GROUP NAME
COURSE
COURSE
Each level on the tree has a slightly different context menu as some have more options than the others. So far I have managed to get a context menu to appear on left click, but all this does is make the biggest context menu appear no matter which node is clicked on and where the course name should be [course name] is displayed instead of the actual course name. But when I right click and then left click the context menu works fine but right click is needed before hand.
Here is part of my asp tree code:
<telerik:RadTreeView ID="UsersTreeView" runat="server" Height="100%" Width="400px"
OnNodeEdit="UsersTreeView_NodeEdit" OnNodeExpand="UsersTreeView_NodeExpand"
OnNodeCollapse="UsersTreeView_NodeCollapse" AllowNodeEditing="True" EnableDragAndDrop="True"
OnContextMenuItemClick="TreeView_ContextMenuItemClick" OnClientContextMenuShowing="UsersTreeView_onClientContextMenuShowing"
OnClientContextMenuItemClick="UsersTreeView_onClientContextMenuItemClicking" OnClientNodeClicking="UsersTreeView_onNodeClicking"
MultipleSelect="True" OnNodeDrop="UsersTreeView_HandleDrop" >
<ContextMenus>
<telerik:RadTreeViewContextMenu ID="UserGroupContextMenu" runat="server">
AND here is the JavaScript being used:
function UsersTreeView_onClientContextMenuShowing(sender, args) {
sender.unselectAllNodes();
var treeNode = args.get_node();
treeNode.set_selected(true);
//enable/disable menu items
UsersTreeView_setMenuItemsState(args.get_menu().get_items(), treeNode);
}
function UsersTreeView_onClientContextMenuItemClicking(sender, args) {
var menuItem = args.get_menuItem();
var treeNode = args.get_node();
menuItem.get_menu().hide();
switch (menuItem.get_value()) {
case "add":
//case "addroot":
case "edit":
//case "user_viewcourses":
case "user_assigncourses":
case "group_assigncourses":
case "group_assigncoursessub":
//case "moveroot":
case "delete":
break;
}
}
AND currently for left click I am using this:
function UsersTreeView_onNodeClicking(sender, args) {
var domEvent = args.get_domEvent();
var menu = $find("<%= UserGroupContextMenu.ClientID %>");
args.set_cancel(true);
menu.show(domEvent);
}
Now I do realize that with my left click code this is needed somewhere:
UsersTreeView_setMenuItemsState(args.get_menu().get_items(), treeNode);
Its used within the default right click code to decide the correct context menu needed but I've tried adding it to my left click code and just cant seem to get it working. I have searched like mad round the forums and Google but for my specific problem I have been unable to find an answer, for all I know it could be impossible to do?
Thanks, James
ALL COURSES [ROOT]
COURSE GROUP NAME
COURSE
COURSE
Each level on the tree has a slightly different context menu as some have more options than the others. So far I have managed to get a context menu to appear on left click, but all this does is make the biggest context menu appear no matter which node is clicked on and where the course name should be [course name] is displayed instead of the actual course name. But when I right click and then left click the context menu works fine but right click is needed before hand.
Here is part of my asp tree code:
<telerik:RadTreeView ID="UsersTreeView" runat="server" Height="100%" Width="400px"
OnNodeEdit="UsersTreeView_NodeEdit" OnNodeExpand="UsersTreeView_NodeExpand"
OnNodeCollapse="UsersTreeView_NodeCollapse" AllowNodeEditing="True" EnableDragAndDrop="True"
OnContextMenuItemClick="TreeView_ContextMenuItemClick" OnClientContextMenuShowing="UsersTreeView_onClientContextMenuShowing"
OnClientContextMenuItemClick="UsersTreeView_onClientContextMenuItemClicking" OnClientNodeClicking="UsersTreeView_onNodeClicking"
MultipleSelect="True" OnNodeDrop="UsersTreeView_HandleDrop" >
<ContextMenus>
<telerik:RadTreeViewContextMenu ID="UserGroupContextMenu" runat="server">
AND here is the JavaScript being used:
function UsersTreeView_onClientContextMenuShowing(sender, args) {
sender.unselectAllNodes();
var treeNode = args.get_node();
treeNode.set_selected(true);
//enable/disable menu items
UsersTreeView_setMenuItemsState(args.get_menu().get_items(), treeNode);
}
function UsersTreeView_onClientContextMenuItemClicking(sender, args) {
var menuItem = args.get_menuItem();
var treeNode = args.get_node();
menuItem.get_menu().hide();
switch (menuItem.get_value()) {
case "add":
//case "addroot":
case "edit":
//case "user_viewcourses":
case "user_assigncourses":
case "group_assigncourses":
case "group_assigncoursessub":
//case "moveroot":
case "delete":
break;
}
}
AND currently for left click I am using this:
function UsersTreeView_onNodeClicking(sender, args) {
var domEvent = args.get_domEvent();
var menu = $find("<%= UserGroupContextMenu.ClientID %>");
args.set_cancel(true);
menu.show(domEvent);
}
Now I do realize that with my left click code this is needed somewhere:
UsersTreeView_setMenuItemsState(args.get_menu().get_items(), treeNode);
Its used within the default right click code to decide the correct context menu needed but I've tried adding it to my left click code and just cant seem to get it working. I have searched like mad round the forums and Google but for my specific problem I have been unable to find an answer, for all I know it could be impossible to do?
Thanks, James