title: How to delete a node from an Ext TreePanel if the node hasn't been rendered
body: <p>I've found that I can't delete nodes that haven't been rendered yet. The following code shows what I mean. I ran it from the Chrome's (and Firebug's) command line while on <a href="http://dev.sencha.com/deploy/dev/exa...dow/hello.html" rel="nofollow">http://dev.sencha.com/deploy/dev/exa...dow/hello.html</a> (since that page has ext preloaded)</p>
  
  <p>I typed each statement separately to make sure there were no issues with asynchronous operations (even though the tree data is in memory)</p>
  
  <pre><code>Ext.getBody.update('');
  // Tree with preloaded nodes in memory 
  var tree = new Ext.tree.TreePanel({ 
     renderTo: Ext.getBody(),  
     width: 300,  
     height: 500,  
     rootVisible: false, 
     loader: new Ext.tree.TreeLoader({preloadChildren:true}), 
     root: new Ext.tree.AsyncTreeNode({ 
       expandend: true, 
       children: [ 
          {text: 'Folder 1', id: 'folder1', leaf: false, children: [ 
              {text: 'File 1', id: 'file1', leaf: true}, 
              {text: 'File 2', id: 'file2', leaf: true} 
          ]} 
       ] 
     }) 
  }); 
  
  // Try to delete 'File 1', notice that the folder has never been expanded 
  tree.getRootNode().childNodes[0].childNodes[0].remove(true); 
  
  // Expand the node and see that 'File 1' is still there 
  tree.getRootNode().childNodes[0].expand(); 
  
  // Delete the first child 1 again, it works now that it's been rendered 
  tree.getRootNode().childNodes[0].childNodes[0].remove(true);
  </code></pre>
  
  <p>Any suggestions on what to do?</p>
  
  <p><strong>ANSWER</strong> </p>
  
  <pre><code>var nodeToRemove = tree.getRootNode().childNodes[0].childNodes[0];
  if (!nodeToRemove.rendered) {
      var children = node.parentNode.attributes.children;
      Ext.each(children, function(child, index){
          if (child.id == nodeToRemove.id) {
              chilren.splice(index, 1);
              return false;
          }
      }) ;
  } else {
      nodeToRemove.remove(true);
  }
  </code></pre>