Client side check if node has children

2 posts, 0 answers
  1. Moon
    Moon avatar
    250 posts
    Member since:
    Apr 2008

    Posted 19 Jul 2009 Link to this post

    In your example:

    On Deletion, you delete the node. I want to first check if there are any children for that node, and if so send a alert. How do I check if the selected TreeNode has children? The below treeNode.Nodes.length doesn't work. thanks!


    case "Delete":




    if (treeNode.Nodes.length > 0) {




    "Please remove content of this directory prior to deletion.");





    else {




    var result = confirm("Are you sure you want to delete the item: " + treeNode.get_text());







  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 20 Jul 2009 Link to this post

    Hi Moon,

    You could use ' treeNode.get_nodes().get_count() ' in order to get the count of child nodes from client side. See the example shown below.

    <script type="text/javascript"
    function onClientContextMenuItemClicking(sender, args) 
        var menuItem = args.get_menuItem(); 
        var treeNode = args.get_node(); 
             . . .  
            case "Delete"
            if (treeNode.get_nodes().get_count() > 0) 
                alert("Please remove content of this directory prior to deletion."); 
                var result = confirm("Are you sure you want to delete the item: " + treeNode.get_text()); 
    You can also checkout the following links which describes the most important functions of the client-side RadTreeNodeCollection object.

Back to Top