RadTreeView - ExpandChildNodes() function doesn't work?

8 posts, 1 answers
  1. Vivek
    Vivek avatar
    38 posts
    Member since:
    Mar 2013

    Posted 17 Sep 2013 Link to this post

    Hi,

       I'm trying to expand child nodes of the currently checked node in my tree view, tried to use the below piece of code which does the following things- 

    1. Find the node by passing node text 
    2. Try to expand child nodes of currenly checked node.

    RadTreeNode node1 = radTreeViewControl.Nodes[0].Nodes.FindNodeByText(contract.Text);            
                      node1.ExpandChildNodes();
                      node1.Expanded = true;

    The node1.ExpandChildNodes() is unable to expand the node, not sure, please let me know the fix or is this something bug in treeview control.


    Thanks,
    Vivek
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 18 Sep 2013 Link to this post

    Hi Vivek,

    Please have a look at the following code I tried which works fine at my end.

    C#:
    RadTreeNode node1 = radTreeViewControl.Nodes[0].Nodes.FindNodeByText(contract.Text);
    node1.ExpandParentNodes();
    node1.ExpandChildNodes();
    node1.Expanded = true;

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Dan
    Dan avatar
    14 posts
    Member since:
    Jul 2013

    Posted 19 Sep 2013 Link to this post

    Hi shinu
    Please help me to achieve the same functionality from client side.
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 19 Sep 2013 Link to this post

    Hi Dan,

    Please have a look into the following JavaScript I tried to expand the child nodes on checking a node and to collapse the node on unchecking it.

    JavaScript:
    <script type="text/javascript">
        function OnClientNodeChecked(sender, args) {
            if (args.get_node().get_checked()) {
                args.get_node().expand();
            }
            else {
                args.get_node().collapse();
            }
        }
    </script>

    Thanks,
    Shinu.
  6. Vivek
    Vivek avatar
    38 posts
    Member since:
    Mar 2013

    Posted 19 Sep 2013 Link to this post

    Thanks Shinu, I also have to collapse root node upto level 1 using code and/or javascript, please help.

    Root Node
           - Contract 1
           - Contract 2

    for more details, pls refer attached snap shot.
  7. Vivek
    Vivek avatar
    38 posts
    Member since:
    Mar 2013

    Posted 20 Sep 2013 Link to this post

    Still waiting for your reply.
  8. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 20 Sep 2013 Link to this post

    Hi Vivek,

    Please have a look at the following JavaScript I tried which works fine at my end.

    JavaScript:
    <script type="text/javascript">
        function OnClientNodeChecked(sender, args) {
            if (args.get_node().get_text() == "Select All 1") {
                if (args.get_node().get_checked()) {
                    args.get_node().expand();
                    var nodes = args.get_node().get_allNodes();
                    var nodeCount = nodes.length;
                    for (var counter = 0; counter < nodeCount; counter++) {
                        nodes[counter].expand();
                        nodes[counter].set_checked(true);
                    }
                }
                else {
                    var nodes = args.get_node().get_allNodes();
                    var nodeCount = nodes.length;
                    for (var counter = 0; counter < nodeCount; counter++) {
                        nodes[counter].collapse();
                        nodes[counter].set_checked(false);
                    }
                }
            }
        }
    </script>

    Thanks,
    Princy.
  9. Vivek
    Vivek avatar
    38 posts
    Member since:
    Mar 2013

    Posted 22 Sep 2013 Link to this post

    Thanks Princy. Thanks a lot. :) It worked.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017