Results 1 to 8 of 8

Thread: changing tree panel checkbox state in 4.1.1, how?

  1. #1
    Sencha Premium Member
    Join Date
    Jul 2012
    Posts
    103
    Answers
    2

    Default Answered: changing tree panel checkbox state in 4.1.1, how?

    The code below, run on a tree panel with some check boxes, never changes the visual state or fires any handlers. All the recipes I've found deal with much older versions of ExtJS.

    Help?

    Code:
    changecheckall: function(panel, value) {
              panel.getRootNode().cascadeBy(function(node) {
                  if (node.data.checked !== undefined && node.data.checked !== null) {
                      node.data.checked = value;
                  }
              });
            }


  2. #2
    Sencha User harman's Avatar
    Join Date
    Jul 2011
    Location
    India
    Posts
    138
    Answers
    2

    Default Basic concept

    At a very basic level do
    Code:
    treeObj.getSelectionModel().select(record(s),[Boolean keepExisting],[Boolean suppressEvent] )
    send boolean according to your requirement.

  3. #3
    Sencha Premium Member
    Join Date
    Jul 2012
    Posts
    103
    Answers
    2

    Default selecting isn't checking

    Selecting the nodes does not check (or uncheck) the checkboxes. I tried it.

    For one thing, the returned selection model is SINGLE. This can't correspond to the checkboxes, since they allow multiple boxes to be selected.

    And, the bottom line is that treeObj.getSelectionModel().selectAll(); has no effect whatsoever on the state of the checkboxes.

  4. #4
    Sencha User harman's Avatar
    Join Date
    Jul 2011
    Location
    India
    Posts
    138
    Answers
    2

    Default

    for that you either need to add the Ext.selection.CheckboxModel
    or if you can get to node object you can just call
    Code:
    nodeObj.checked=true
    And again this is not tested but i hope will work

  5. #5
    Sencha Premium Member
    Join Date
    Jul 2012
    Posts
    103
    Answers
    2

    Default

    Adding the checkbox model ends up with two sets of checkboxes, the native ones of the tree and the checkbox model. Honestly, I think you are barking up the wrong tree.

  6. #6
    Sencha Premium Member
    Join Date
    Jul 2012
    Posts
    103
    Answers
    2

    Default

    I have a partial answer to my own question. The code below switches the visual state, but does not fire the event on the panel to inform that anything has changed.

    Code:
     changecheckall: function(panel, value) {
                panel.getRootNode().cascadeBy(function(node) {
                    if (node.data.checked !== null) {
                        node.set("checked", value);
                    }
                });
            }

  7. #7
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,410
    Answers
    716

  8. #8
    Sencha Premium Member
    Join Date
    Jul 2012
    Posts
    103
    Answers
    2

    Default

    Except for the event management ,which also requires:

    panel.fireEvent('checkchange', node, value, null);

Tags for this Thread

Posting Permissions

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