This is a migrated thread and some comments may be shown as answers.

Context menu for empty tree view (RadTreeView)?

1 Answer 67 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Roland Klug
Top achievements
Rank 1
Roland Klug asked on 28 Jun 2010, 02:26 PM
Hello,

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

Thanks,
Roland

1 Answer, 1 is accepted

Sort by
0
Nikolay Tsenkov
Telerik team
answered on 01 Jul 2010, 02:52 PM
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
Tags
TreeView
Asked by
Roland Klug
Top achievements
Rank 1
Answers by
Nikolay Tsenkov
Telerik team
Share this question
or