So I have been working with RadTreeView and it's context menu with succes, to test if it could solve a problem of mine. Next problem was that the RadTreeNodes could not contain enough information, so I created my own TreeNodes, and extended those to RadTreeNode. I could create and add the new Nodes to the RadTreeNode without any problems.
But when I tested my treeview, it's showed all nodes i added. When i rightclick the contextmenu pops up, but when clicking on any menuitem, the OnContextMenuItemClick event is not fired. I tried remove all of my nodes, and only add one original RadTreeNode. This works.
I found out that the problem also affects OnNodeDrop and OnNodeEdit events.
It sounds like using costum nodes corrupts some event system. Is this true?
Here are my code snippets:
Custom node:
TreeView:
And here I add a node to the treeview:
if anyone have an answer to this, I would be happy.
But when I tested my treeview, it's showed all nodes i added. When i rightclick the contextmenu pops up, but when clicking on any menuitem, the OnContextMenuItemClick event is not fired. I tried remove all of my nodes, and only add one original RadTreeNode. This works.
I found out that the problem also affects OnNodeDrop and OnNodeEdit events.
It sounds like using costum nodes corrupts some event system. Is this true?
Here are my code snippets:
Custom node:
public class ReportTreeNode : RadTreeNode { public ReportTreeNode(String text) : base(text) { Locked = false; } public ReportTreeNode(String text, String value) : base(text, value) { Locked = false; } public ReportTreeNode(String text, String value, String image) : base(text, value) { Locked = false; ImageUrl = image; } public ReportTreeNode(String text, String value, String image, String type) : base(text, value) { NodeType = type; Locked = false; ImageUrl = image; } public bool Locked { get; set;} /// <summary> /// The report node type. eg. Section, textarea, pagebreak etc. /// </summary> public String NodeType { get; set; } /// <summary> /// Returns the depth location of the node /// </summary> /// <returns></returns> public int getDepthOfNode() { int result = 0; foreach (char c in FullPath) { if (c == '/') result++; } return result; } }TreeView:
<telerik:RadScriptManager ID="scriptmanager" runat="server" /> <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" ><img src="anidog2.gif" /></telerik:RadAjaxLoadingPanel> <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1"> <asp:Literal ID="statusMessage" runat="server"></asp:Literal><br /> <telerik:RadTreeView ID="template" runat="server" EnableDragAndDrop="true" EnableDragAndDropBetweenNodes="true" OnContextMenuItemClick="dynamicMenu_ContextMenuItemClick" OnNodeDrop="dynamicMenu_OnNodeDrop" OnNodeEdit="dynamicMenu_OnNodeEdit" AllowNodeEditing="true" OnLoad="templateOnInit"> <ContextMenus> <telerik:RadTreeViewContextMenu> <Items> <telerik:RadMenuItem Text="Add" Value="none" ImageUrl="application_add.png"> <Items> <telerik:RadMenuItem Text="Section" Value="add:section" ImageUrl="section.png"/> <telerik:RadMenuItem Text="Textarea" Value="add:textarea" ImageUrl="testArea.png"/> </Items> </telerik:RadMenuItem> <telerik:RadMenuItem Text="Add Custom Section" Value="addCustom" ImageUrl="application_add.png" runat="server" /> <telerik:RadMenuItem Text="Delete" Value="delete" ImageUrl="application_delete.png" runat="server" /> </Items> </telerik:RadTreeViewContextMenu> </ContextMenus> </telerik:RadTreeView> </telerik:RadAjaxPanel>And here I add a node to the treeview:
protected void templateOnInit(object sender, EventArgs e) { if(IsPostBack) return; template.Nodes.Clear(); ReportTreeNode report = new ReportTreeNode("Report", "report", picturepath + "/report.png", "report"); report.Locked = true; template.Nodes.Add(report); return; }if anyone have an answer to this, I would be happy.