RadTreeNodeData missing properties

4 posts, 0 answers
  1. Thomas
    Thomas avatar
    4 posts
    Member since:
    Mar 2008

    Posted 28 Apr 2009 Link to this post

    How could I use in a WebService to load the childs of the parent with RadTreeNodeData like ToolTip, Expanded and AllowEdit?

    All other properties (eg: Text, Value) are in the RadTreeNodeData object like RadTreeNode.


    Telerik.Web.UI.RadTreeNode node = new Telerik.Web.UI.RadTreeNode();
    node.Text = "new node";
    node.Value = "25";
    node.ToolTip = row["Tooltip"].ToString();

    RadTreeNodeData nodeData = new RadTreeNodeData();
    nodeData.Text = "new node";
    nodeData.Value = "25";

  2. Veselin Vasilev
    Veselin Vasilev avatar
    2992 posts

    Posted 01 May 2009 Link to this post

    Hello Thomas,

    There are two approaches you can use in this way.

    First approach - using a custom class:

    1. Create a class that inherits the RadTreeNodeData class and add the ToolTop property to it:

    public class CustomRadTreeNodeData : RadTreeNodeData 
        public string ToolTip; 

    2. Define the WebMethod as follows:

    public CustomRadTreeNodeData[] GetNodesWithToolTips() 
        List<CustomRadTreeNodeData> nodes = new List<CustomRadTreeNodeData>(); 
        for (int i = 1; i < 11; i++) 
            CustomRadTreeNodeData node = new CustomRadTreeNodeData(); 
            node.Text = "node " + i.ToString(); 
            node.ToolTip = "Tooltip for " + node.Text; 
        return nodes.ToArray(); 

    3. Set the tooltip of the node in the OnClientNodeDataBound event:

    <script type="text/javascript"
    function OnClientNodeDataBoundHandler(sender, e) 
        var node = e.get_node(); 

    The second option is similar, but instead of creating a new class you use the Attributes dictionary to store the ToolTip:

    1. Add the ToolTip custom attribute:

    public RadTreeNodeData[] GetNodesWithToolTips() 
        List<RadTreeNodeData> nodes = new List<RadTreeNodeData>(); 
        for (int i = 1; i < 11; i++) 
            RadTreeNodeData node = new RadTreeNodeData(); 
            node.Text = "node " + i.ToString(); 
            node.Attributes["ToolTip"] = "new tooltip for " + node.Text; 
        return nodes.ToArray(); 

    2. Set the tooltip of the node in the OnClientNodeDataBound event:

    <script type="text/javascript"
    function OnClientNodeDataBoundHandler(sender, e) 
        var node = e.get_node(); 

    I hope this helps.

    Best wishes,
    Veselin Vasilev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Claudiu
    Claudiu avatar
    1 posts
    Member since:
    Oct 2011

    Posted 23 Mar 2012 Link to this post

    hi Veselin,

    I'm using the technique described below (custom RadTreeNodeData class) for passing more information for each node. However when I do access the custom properties on the client-site, they do not exist (I'm getting a value of "undefined").

    Here is how I've done it:
    public class CustomRadTreeNodeData  : RadTreeNodeData
    public int CustomProperty { get; set; }

    On the client-side I have the following handler bound to OnClientNodeDataBound event:
    function clientNodeDataBound(sender, eventArgs) {
                var node = eventArgs.get_node();
                var dataItem = eventArgs.get_dataItem();
                var nodeType = dataItem.CustomProperty; // this is 'undefined'

    Am I doing something wrong here?

  4. Plamen
    Plamen avatar
    2817 posts

    Posted 27 Mar 2012 Link to this post

    Hello Claudiu,

    I will recommend you to check if the CustomRadTreeNodeData is set everywhere properly in the web method as well.

    I am attaching a sample working project.

    Hope this will help you.

    Plamen Zdravkov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top