RadTreeView - cascading onNodeClick to children/grandchildren

2 posts, 0 answers
  1. Randy
    Randy avatar
    1 posts
    Member since:
    Feb 2013

    Posted 20 Mar 2013 Link to this post

    I have a 3-tier RadTreeView and I've managed to use javascript to cascade an "onNodeClick" to the children but it's missing the grandchildren.  Can someone please help?

    function onNodeClick(sender, args)

                  {

                       var node = args.get_node();

                      if (node.get_value() == 0)

                           {

                            var childNodes = node.get_nodes();

                            for (var i = 0; i < childNodes.get_count(); i++)

                            {

                                 var childNode = childNodes.getNode(i);

                                 childNode.select();

                            }

                            }

                  }

  2. Kevin
    Kevin avatar
    360 posts
    Member since:
    Jul 2012

    Posted 21 Mar 2013 Link to this post

    Hey Randy,

    You can create a recursive function that goes through all the child nodes. Something like this:
    function SelectedNodes(nodes) {
                if (nodes != null) {
                    for (var i = 0; i < nodes.get_count(); i++) {
                        var childNode = nodes.getNode(i);
     
                        childNode.select();
     
                        SelectedNodes(childNode.get_nodes());
                    }
                }
            }
            function onNodeClick(sender, args) {
                var node = args.get_node();
     
                if (node.get_value() == 0) {
                    SelectedNodes(node.get_nodes());
                }
            }


    I hope that helps.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top