Results 1 to 3 of 3

Thread: TreeNodes checked when parent is checked

  1. #1
    Sencha User
    Join Date
    Oct 2012
    Posts
    31
    Answers
    2

    Default Answered: TreeNodes checked when parent is checked

    Hi,

    1. I'm using ExtJS 3.4 TreePanel. I'd like to know if there is a way (function or attribute or ... that I didn't find) to automatically check children nodes when their parent is checked and to uncheck parent when all of its children are unchecked?

    2. To uncheck the check box of an initially checked=true node, is the node.checked attribute that should be set to false or something else? I tried with the uncheck attribute but it didn't work.

    Regards.

  2. Hi yo_haha,

    Try the following code -
    Code:
    var node = treePanel.getNodeById('your-id');
    node.eachChild(function(n) {
        n.getUI().toggleCheck(true);
    });
    If you want this to work whole subtree of the current node, you'll have to do some recursion like-
    Code:
    treePanel.on('checkchange', function(node, checked) {
        node.eachChild(function(n) {
            n.getUI().toggleCheck(checked);
        });
    });

  3. #2
    Sencha User sword-it's Avatar
    Join Date
    May 2012
    Location
    Istanbul
    Posts
    1,335
    Answers
    124

    Default

    Hi yo_haha,

    Try the following code -
    Code:
    var node = treePanel.getNodeById('your-id');
    node.eachChild(function(n) {
        n.getUI().toggleCheck(true);
    });
    If you want this to work whole subtree of the current node, you'll have to do some recursion like-
    Code:
    treePanel.on('checkchange', function(node, checked) {
        node.eachChild(function(n) {
            n.getUI().toggleCheck(checked);
        });
    });
    sword-it.com, Sencha Developer House in Turkey - Istanbul University Technopark Suite 204.

  4. #3
    Sencha User
    Join Date
    Oct 2012
    Posts
    31
    Answers
    2

    Default

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •