[CLOSED] Check child nodes treepanel

  1. #1

    [CLOSED] Check child nodes treepanel

    Last edited by Baidaly; Nov 10, 2012 at 3:47 AM.
  2. #2
    Hi Antonio,

    Here are some recommendations how to achieve it.
    http://forums.ext.net/showthread.php...ll=1#post93516
  3. #3

    Solved

    That's it! Thank you.

    var onCheckChange = function (node, checked) {
            if (!this.locked) {
            this.locked = true;
      
            if (node.hasChildNodes()) { 
                node.cascade(function (childNode) {
                    childNode.set("checked", checked);
                });      
            }
    
            var nodoPadre = node.parentNode; 
                if (nodoPadre != null) {
                    if (checked == false) { 
                        nodoPadre.set("checked", false);
                        var nodoPadre2 = nodoPadre.parentNode;
                        if (nodoPadre2 != null) {
                            nodoPadre2.set("checked", false);
                        }
                    } else{
                        var todosCheck = true;
                        nodoPadre.cascade(function (childNode2) {
                            if ((childNode2.data.checked == false) && (nodoPadre.data.text != childNode2.data.text)) {todosCheck = false; }
                        });   
                        if (todosCheck == true) { nodoPadre.set("checked", true); }
    
                        var nodoPadre2 = nodoPadre.parentNode; 
                        if (nodoPadre2 != null) {
                        var todosCheck2 = true;
                            nodoPadre2.cascade(function (childNode3) {
                                if ((childNode3.data.checked == false) && (nodoPadre2.data.text != childNode3.data.text)) {todosCheck2 = false; }
                            });   
                            if (todosCheck2 == true) { nodoPadre2.set("checked", true); }
                        }
                    }
                }
            this.locked = false;
        }
    };
  4. #4
    Thank you for sharing the solution! It can help someone on the forums in the future.
  5. #5
    Quote Originally Posted by Antonio09 View Post
    That's it! Thank you.

    var onCheckChange = function (node, checked) {
            if (!this.locked) {
            this.locked = true;
      
            if (node.hasChildNodes()) { 
                node.cascade(function (childNode) {
                    childNode.set("checked", checked);
                });      
            }
    
            var nodoPadre = node.parentNode; 
                if (nodoPadre != null) {
                    if (checked == false) { 
                        nodoPadre.set("checked", false);
                        var nodoPadre2 = nodoPadre.parentNode;
                        if (nodoPadre2 != null) {
                            nodoPadre2.set("checked", false);
                        }
                    } else{
                        var todosCheck = true;
                        nodoPadre.cascade(function (childNode2) {
                            if ((childNode2.data.checked == false) && (nodoPadre.data.text != childNode2.data.text)) {todosCheck = false; }
                        });   
                        if (todosCheck == true) { nodoPadre.set("checked", true); }
    
                        var nodoPadre2 = nodoPadre.parentNode; 
                        if (nodoPadre2 != null) {
                        var todosCheck2 = true;
                            nodoPadre2.cascade(function (childNode3) {
                                if ((childNode3.data.checked == false) && (nodoPadre2.data.text != childNode3.data.text)) {todosCheck2 = false; }
                            });   
                            if (todosCheck2 == true) { nodoPadre2.set("checked", true); }
                        }
                    }
                }
            this.locked = false;
        }
    };
    Hi Antonio09,

    This thread is very helpful.. Nice.. :) Thx

Similar Threads

  1. [CLOSED] check/uncheck for all child node in treepanel
    By majestic in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Nov 15, 2012, 3:11 AM
  2. Blocking load child nodes with dbclick of treegrid row
    By Thiago Nogueira in forum 1.x Help
    Replies: 1
    Last Post: Nov 29, 2010, 12:42 PM
  3. [CLOSED] Unselect child nodes of an AsyncTreeNode in javascript
    By deejayns in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Nov 23, 2010, 6:03 PM
  4. How to expand all child nodes for current node?
    By dbassett74 in forum 1.x Help
    Replies: 2
    Last Post: May 26, 2009, 2:53 PM
  5. How do I clear out a child nodes from a TreeNode?
    By dbassett74 in forum 1.x Help
    Replies: 3
    Last Post: May 26, 2009, 1:39 PM

Posting Permissions