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

get child node count.

5 Answers 288 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Karl Ranville
Top achievements
Rank 1
Karl Ranville asked on 16 Jul 2013, 02:01 AM
Hi

I want to get the count of child nodes of a particular node in js? I searched the docs but didnt get anything useful. So please help me.

Thanks for your replies
Karl

5 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 16 Jul 2013, 06:45 AM
Hi Karl,

Please have a look into the following JavaScript code i tried to get the count of all child nodes of a particular RadTreeNode. If you need the count of immediate child nodes only, use the get_nodes().get_count() instead of get_allNodes() method.

JavaScript:
<script type="text/javascript">
    function getChildnodecount() {
        var radtreeview = $find('<%=RadTreeView1.ClientID %>');
        alert("Child Nodes Count : " + radtreeview.findNodeByText("Node 1").get_allNodes().length);
    }
</script>

Thanks,
Shinu.
0
Karl Ranville
Top achievements
Rank 1
answered on 23 Sep 2013, 02:56 AM
Hi shinu
There is a treeview with three levels of nodes each with child nodes. How to automatically check a parent node when the child node is checked?
0
Shinu
Top achievements
Rank 2
answered on 23 Sep 2013, 06:07 AM
Hi Karl Ranville,

Please try the following JavaScript that I have tried to check the parent node when the child node is checked.

JavaScript:
<script type="text/javascript">
    function OnClientNodeChecked1(sender, args) {
        var node = args.get_node();      
        if(node.get_level()!=0)
            node.get_parent().check(true);
    }
</script>

Thanks,
Shinu.

0
Karl Ranville
Top achievements
Rank 1
answered on 24 Sep 2013, 02:40 AM
Thankyou shinu. Now the parent node remain checked even if no child is checked. How to uncheck parent if no child is checked?
0
Accepted
Shinu
Top achievements
Rank 2
answered on 24 Sep 2013, 03:58 AM
Hi Karl,

This feature is available out of the box. Set the CheckChildNodes, TriStateCheckBoxes property of the RadTreeView to True to achieve your requirement. You don't need the previous JavaScript now.

Thanks,
Shinu.
Tags
TreeView
Asked by
Karl Ranville
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Karl Ranville
Top achievements
Rank 1
Share this question
or