TreeNode and childs Question

3 posts, 0 answers
  1. Hossam
    Hossam avatar
    5 posts
    Member since:
    Jan 2014

    Posted 04 Jan 2014 Link to this post

    i want to add an image to all tree nodes and all nodes childs and so on in javascript ... 
    how to make it please ??
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 05 Jan 2014 Link to this post

    Hi Hossam,

    Please have a look into the following code snippet to add an image to the RadTreeNode.

    JavaScript:
    <script type="text/javascript">
        function pageLoad() {
            var treeView = $find("<%= RadTreeView1.ClientID %>");
            treeView.trackChanges();
            var node = new Telerik.Web.UI.RadTreeNode();
            node.set_text("Node1");
            node.set_imageUrl("delete-icon.png");
            treeView.get_nodes().add(node);
            var node1 = new Telerik.Web.UI.RadTreeNode();
            node1.set_text("Node1.2");
            node1.set_imageUrl("delete-icon.png");
            node.get_nodes().add(node1)
            treeView.commitChanges();
        }
    </script>

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Hossam
    Hossam avatar
    5 posts
    Member since:
    Jan 2014

    Posted 06 Jan 2014 Link to this post

    Thanx !! You Helped me to find the correct way to get all nodes and their child and so on,,,,
    and this code worked perfeclty for me :) It displays nodes that only have childs .
    function GetNodes()
    {
    var tree = $find("<%= RadTreeView1.ClientID %>");
    var nodes = tree.get_allNodes();
    for (var i = 0; i< nodes.length; i++) {
    var childs = nodes[i].get_allNodes();
    if(childs.length >0) {
    alert(nodes[i].get_text());
    }
    }
    }
Back to Top