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

RadTreeView - ExpandChildNodes() function doesn't work?

7 Answers 148 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Vivek
Top achievements
Rank 2
Vivek asked on 17 Sep 2013, 07:43 AM
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

7 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 18 Sep 2013, 12:43 PM
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.
0
Dan
Top achievements
Rank 1
answered on 19 Sep 2013, 07:46 AM
Hi shinu
Please help me to achieve the same functionality from client side.
0
Shinu
Top achievements
Rank 2
answered on 19 Sep 2013, 08:54 AM
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.
0
Vivek
Top achievements
Rank 2
answered on 19 Sep 2013, 12:12 PM
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.
0
Vivek
Top achievements
Rank 2
answered on 20 Sep 2013, 11:11 AM
Still waiting for your reply.
0
Accepted
Princy
Top achievements
Rank 2
answered on 20 Sep 2013, 01:12 PM
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.
0
Vivek
Top achievements
Rank 2
answered on 22 Sep 2013, 11:40 AM
Thanks Princy. Thanks a lot. :) It worked.
Tags
TreeView
Asked by
Vivek
Top achievements
Rank 2
Answers by
Shinu
Top achievements
Rank 2
Dan
Top achievements
Rank 1
Vivek
Top achievements
Rank 2
Princy
Top achievements
Rank 2
Share this question
or