get child node count.

6 posts, 2 answers
  1. Karl Ranville
    Karl Ranville avatar
    28 posts
    Member since:
    Mar 2013

    Posted 15 Jul 2013 Link to this post

    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
  2. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 16 Jul 2013 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Karl Ranville
    Karl Ranville avatar
    28 posts
    Member since:
    Mar 2013

    Posted 22 Sep 2013 Link to this post

    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?
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 23 Sep 2013 Link to this post

    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.

  6. Karl Ranville
    Karl Ranville avatar
    28 posts
    Member since:
    Mar 2013

    Posted 23 Sep 2013 Link to this post

    Thankyou shinu. Now the parent node remain checked even if no child is checked. How to uncheck parent if no child is checked?
  7. Answer
    Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 23 Sep 2013 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017