Context menu for empty tree view (RadTreeView)?

2 posts, 0 answers
  1. Roland Klug
    Roland Klug avatar
    25 posts
    Member since:
    Dec 2002

    Posted 28 Jun 2010 Link to this post

    Hello,

    is it possible to add a context menu on an empty tree view, i.e. a tree view without any nodes?

    Thanks,
    Roland
  2. Nikolay Tsenkov
    Admin
    Nikolay Tsenkov avatar
    734 posts

    Posted 01 Jul 2010 Link to this post

    Hi Roland Klug,

    Well, you can create it declarative in the markup of the tree, and then add nodes on the client.
    Here is a brief example that I prepared for your case:
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
     
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
         
        <asp:ScriptManager runat="server">
        </asp:ScriptManager>
     
        <script type="text/javascript">
            function onLoad(sender) {
                var tree=sender;
                var node=new Telerik.Web.UI.RadTreeNode();
                node.set_text("Node");
                tree.get_nodes().add(node);
            }
        </script>
     
        <telerik:RadTreeView runat="server" ID="RadTreeView1" OnClientLoad="onLoad">
            <ContextMenus>
                <telerik:RadTreeViewContextMenu ID="menu">
                    <Items>
                        <telerik:RadMenuItem Text="Item1" />
                        <telerik:RadMenuItem Text="Item2" />
                        <telerik:RadMenuItem Text="Item3" />
                        <telerik:RadMenuItem Text="Item4" />
                    </Items>
                </telerik:RadTreeViewContextMenu>
            </ContextMenus>
        </telerik:RadTreeView>
     
        </div>
        </form>
    </body>
    </html>

    Hope this is going to help you!


    Regards,
    Nikolay Tsenkov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top