title: In-built method to deselect child nodes of a node in ExtJs 4 tree panel
body: <p>I am using ExtJs tree panel. Is there any in-build method or property which will deselect all the child nodes of a node when you select that node.</p>
  
  <p>So consider the below image, assuming the nodes in yellow back color is already selected. If I select 1.1 now, system should automatically deselect 1.1.2 &amp; if I selected node 1, it should deselect 1.1.2, .1.2.1, 1.2.2.</p>
  
  <p>Please provide your suggestions</p>
  
  <p><img src="https://i.stack.imgur.com/TwVlc.png" alt="enter image description here"></p>
  
  <pre><code>Ext.create('Ext.tree.Panel', {
      title: 'Simple Tree',
      renderTo: Ext.getBody(),
      width: 400,
      height: 400,
  
      store: {
          root: {
              expanded: true,
              children: [{
                  text: "1 detention",
                  expanded: true,
                  "checked": false,
                  children: [{
                      text: '1.1 foo',
                      leaf: true,
                      "checked": false
                  }, {
                      text: '1.2 bar',
                      leaf: true,
                      "checked": false
                  }]
              }, {
                  text: "2 homework",
                  expanded: true,
                  "checked": false,
                  children: [{
                      text: "2.1 book report",
                      leaf: true,
                      "checked": false
                  }, {
                      text: "2.2 algebra",
                      expanded: true,
                      "checked": false,
                      children: [{
                          text: "2.2.1 buy lottery tickets",
                          leaf: true,
                          "checked": false
                      }, {
                          text: "2.2.2 buy lottery tickets 2",
                          leaf: true,
                          "checked": false
                      }]
                  }]
              }, {
                  text: "3 buy lottery tickets",
                  leaf: true,
                  "checked": false
              }]
          }
      },
      useArrows: false,
      rootVisible: false,
      selModel: {
          mode: 'SIMPLE'
      },
      listeners: {
          deselect: function (tree, record) {
              if (record.data.text === '1 detention') {
  
              }
          },
          select: function (tree, record) {
              var parentNode = record.parentNode;
  
              // Deselect children
              function deselectChildren(record) {
                  tree.deselect(record.childNodes, false);
                  record.eachChild(deselectChildren);
              }
              deselectChildren(record);
  
              // See if all siblings are selected now
              var allSiblingSelected = false;
              if (parentNode) {
                  allSiblingSelected = parentNode.childNodes.reduce(function (previous, node) {
                      return previous &amp;&amp; tree.isSelected(node)
                  }, true);
              }
  
              if (allSiblingSelected) {
                  tree.select(parentNode, true); // will trigger req 1
              }
  
              // Deselect ancestors
              else {
                  while (parentNode) {
                      tree.deselect(parentNode);
                      parentNode = parentNode.parentNode;
                  }
              }
          }
      }
  });
  </code></pre>