Ok this really has me stumped...I used the cascade method() and <font face="Arial" size="2">TreePanel.getNodeById</font> as Matt suggested, thank you very much for that by the way.  They helped me a great deal ^.^<br><br>However, it seems cascade will only traverse leaf nodes if one of them is checked.  If none of the leafs have been checked, cascade rudely ignores them :(<br>
<br>I need some tips on how to force a cascade on leafs which have never been switched on.  Thanks for your time and kind responses :)<br><br>Here is some code that I have wrote, I am sending the relevant snippet:<br><br>
function checkHandler(item, checked) {<br>                    var tibetContainer, chineseContainer;<br>                    <br>                    if(item.text == &#39;Tibetan&#39;){<br>  <br>                        tibetContainer = new Ext.tree.TreeNode({<br>
                            text: &quot;Tibetan Labels&quot;,<br>                            expanded: true,<br>                            id: &#39;tibet&#39;<br>                        });<br><br>                        tibetContainer.appendChild(new GeoExt.tree.OverlayLayerContainer({<br>
                            text: &quot;Lands (Tibetan trans)&quot;,<br>                            layerStore: tibLands,<br>                            expanded: false,<br>                            loader: {param: &quot;LAYERS&quot;}<br>
                        }));<br><br>                        tibetContainer.appendChild(new GeoExt.tree.OverlayLayerContainer({<br>                            text: &quot;Natural Selection (Tibetan trans)&quot;,<br>                            layerStore: tibNaturalLayers,<br>
                            expanded: false,<br>                            loader: {param: &quot;LAYERS&quot;}<br>                        }));<br><br>                        tibetContainer.appendChild(new GeoExt.tree.OverlayLayerContainer({<br>
                            text: &quot;Points of Interest (Tibetan trans)&quot;,<br>                            layerStore: tibPointOfInterest,<br>                            expanded: false,<br>                            loader: {param: &quot;LAYERS&quot;}<br>
                        }));<br><br>                        if(<a href="http://layerRoot.lastChild.id">layerRoot.lastChild.id</a> != &#39;tibet&#39;){<br>                            layerRoot.appendChild(tibetContainer);<br>
                        <br>                            if(layerRoot.getOwnerTree().getNodeById(&#39;chinese&#39;)){<br>                                var j = 0;<br>                                var selectedLayers = new Array();<br>
                                var layersChecked = new Array();<br>                                while(layerRoot.getOwnerTree().getNodeById(&#39;chinese&#39;).hasChildNodes()){<br>                                    layerRoot.getOwnerTree().getNodeById(&#39;chinese&#39;).firstChild.eachChild(function(node) {          <br>
                                        if (node.isLeaf() &amp;&amp; node.ui.isChecked()) {  <br>                                            layersChecked[j] = node.text; <br>                                            node.ui.toggleCheck(false);<br>
                                            j++;<br>                                        }//end if  <br>                                        <br>                                        return layersChecked;<br>                                    });//end cascade<br>
<br>                                    layerRoot.getOwnerTree().getNodeById(&#39;chinese&#39;).removeChild(layerRoot.getOwnerTree().getNodeById(&#39;chinese&#39;).firstChild);<br>                                }//end while<br>
                                layerRoot.removeChild(layerRoot.getOwnerTree().getNodeById(&#39;chinese&#39;));<br><br>                                selectedLayers = layersChecked;<br>                                if(layerRoot.getOwnerTree().getNodeById(&#39;tibet&#39;).hasChildNodes()){<br>
                                    var i = 0;<br>                                    var children = new Array();<br>                                    for(var c = 0; c &lt; layerRoot.getOwnerTree().getNodeById(&#39;tibet&#39;).childNodes.length; c++){<br>
                                        //children[c] = layerRoot.getOwnerTree().getNodeById(&#39;tibet&#39;).childNodes[c].id;<br>                                        //alert(children[c]);<br>                                        children[c] = layerRoot.getOwnerTree().getNodeById(&#39;tibet&#39;).childNodes[c].id;<br>
                                        alert(children[c]);<br>                                    <br>                                    <br>                                        <br>                                        layerRoot.getOwnerTree().getNodeById(&#39;tibet&#39;).childNodes[c].cascade(function(node) {  <br>
                                            alert(layerRoot.getOwnerTree().getNodeById(&#39;tibet&#39;).firstChild.text + &quot; and &quot; + layerRoot.getOwnerTree().getNodeById(&#39;tibet&#39;).childNodes[c].text); <br>
                                            alert(node.text);  //This is how I know it is not traversing to the leafs :(   <br>                                            if (node.isLeaf() &amp;&amp; (node.ui.isChecked() == false)) {  <br>
                                                alert(node.text + &quot;not checked&quot;);<br>                                                if (node.text == selectedLayers[i]) {<br>                                                    node.ui.toggleCheck(true);<br>
                                                    alert(selectedLayers[i]);<br>                                                    i++;<br>                                                }//end if<br>                                            }//end if  <br>
<br>                                        });//end cascade<br>                                    }//end for<br>                                }//end if<br>                            }//end if(layerRoot.getOwnerTree().getNodeById(&#39;chinese&#39;))<br>
                        }//end if(<a href="http://layerRoot.lastChild.id">layerRoot.lastChild.id</a> != &#39;tibet&#39;)<br>                    }//end if(item.text == &#39;Tibetan&#39;)<br><br><br><br><br>elshae<br><br><br>
<br><br><div class="gmail_quote">On Wed, Oct 20, 2010 at 2:29 PM, Matt Priour <span dir="ltr">&lt;<a href="mailto:mpriour@kestrelcomputer.com">mpriour@kestrelcomputer.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">




<div style="padding-right: 10px; padding-left: 10px; padding-top: 15px;" name="Compose message area">
<div><font face="Arial" size="2">You are using some very fragile methods 
there.</font></div>
<div><font face="Arial" size="2">Rather than depending on lastChild &amp; firstChild 
and the fact that they may or may not only contain leaf nodes, etc..., you 
should be using the standard ExtJS TreeNode walking functions.</font></div>
<div><font face="Arial" size="2"></font> </div>
<div><font face="Arial" size="2">node.bubble</font></div>
<div><a title="http://dev.sencha.com/deploy/dev/docs/?class=Ext.tree.TreeNode#Ext.data.Node-bubble
CTRL + Click to follow link" href="http://dev.sencha.com/deploy/dev/docs/?class=Ext.tree.TreeNode#Ext.data.Node-bubble" target="_blank">http://dev.sencha.com/deploy/dev/docs/?class=Ext.tree.TreeNode#Ext.data.Node-bubble</a></div>

<div><font face="Arial" size="2"></font> </div>
<div><font face="Arial" size="2">node.cascade</font></div>
<div><a title="http://dev.sencha.com/deploy/dev/docs/?class=Ext.tree.TreeNode#Ext.data.Node-cascade
CTRL + Click to follow link" href="http://dev.sencha.com/deploy/dev/docs/?class=Ext.tree.TreeNode#Ext.data.Node-cascade" target="_blank">http://dev.sencha.com/deploy/dev/docs/?class=Ext.tree.TreeNode#Ext.data.Node-cascade</a></div>

<div> </div>
<div><font face="Arial" size="2">node.eachChild</font></div>
<div><a title="http://dev.sencha.com/deploy/dev/docs/?class=Ext.tree.TreeNode#Ext.data.Node-eachChild
CTRL + Click to follow link" href="http://dev.sencha.com/deploy/dev/docs/?class=Ext.tree.TreeNode#Ext.data.Node-eachChild" target="_blank">http://dev.sencha.com/deploy/dev/docs/?class=Ext.tree.TreeNode#Ext.data.Node-eachChild</a></div>

<div> </div>
<div><font face="Arial" size="2">Bubble walks up the tree toward the root 
node, starting with the node it is called on</font></div>
<div><font face="Arial" size="2">Cascade walks down the tree (through each child 
branch as well) starting with the node it is called on</font></div>
<div><font face="Arial" size="2">EachChild iterates over ONLY the child nodes of the 
node it is called on. It will NOT continue any further down the child branches 
and will not include the node it is called on</font></div>
<div><font face="Arial" size="2"></font> </div>
<div><font face="Arial" size="2">You should be able to use these functions to 
collect the information you need from your layer tree (node.getUI().isChecked(), 
etc..) and then reapply it to the tree formed with the different layer 
store.</font></div>
<div><font face="Arial" size="2"></font> </div>
<div><font face="Arial" size="2">If you want to start at a certain node other than 
the Root Node, then assign that node an id and find it in the tree panel using 
the TreePanel.getNodeById function</font></div>
<div><a title="http://dev.sencha.com/deploy/dev/docs/?class=Ext.tree.TreePanel#Ext.data.Tree-getNodeById
CTRL + Click to follow link" href="http://dev.sencha.com/deploy/dev/docs/?class=Ext.tree.TreePanel#Ext.data.Tree-getNodeById" target="_blank">http://dev.sencha.com/deploy/dev/docs/?class=Ext.tree.TreePanel#Ext.data.Tree-getNodeById</a></div>

<div> </div>
<div><font face="Arial" size="2">Matt Priour</font></div>
<div><font face="Arial" size="2">Kestrel Computer Consulting</font></div>
<div><font face="Arial" size="2"></font> </div>
<div style="font: 10pt Tahoma;">
<div><br></div>
<div style="background: none repeat scroll 0% 0% rgb(245, 245, 245);">
<div><b>From:</b> <a title="itintern12@gmail.com" href="mailto:itintern12@gmail.com" target="_blank">IT Intern</a> </div>
<div><b>Sent:</b> Wednesday, October 20, 2010 12:02 PM</div>
<div><b>To:</b> <a title="users@geoext.org" href="mailto:users@geoext.org" target="_blank">users@geoext.org</a> </div>
<div><b>Subject:</b> Re: [Users] Keeping Selected Layers When Replacing Child 
Nodes</div></div></div><div><div></div><div class="h5">
<div><br></div>Ok so far I have been able to find a way to access the properties 
of nodes...now I am struggling to find out if there is anyway to access the 
properties of the node&#39;s leafs?  If anyone know please help me, I think if 
I have that I will be able to carry out the desired task :)<br><br>Some code of 
my approach:<br><br>var i;<br>        
                
    var j = 0;<br>        
                
    var selectedLayers = new Array();<br>    
                
        
while(layerRoot.lastChild.hasChildNodes()){<br>        
                
        
alert(layerRoot.lastChild.firstChild.childNodes.length); //This returns 0, but 
the childNodes here are leafs :(<br>        
                
        for(i = 0; i &lt; 
layerRoot.lastChild.firstChild.childNodes.length; i++){<br>    
                
                
if(layerRoot.lastChild.firstChild.childNodes[i].isSelected()){<br>    
                
                
    selectedLayers[j] = 
layerRoot.lastChild.firstChild.childNodes[i].attributes.text;<br>    
                
                
    alert(selectedLayers[j]);<br>    
                
                
    j++;<br>        
                
            } 
<br>                
                
}<br>                
                
<br>                
                
layerRoot.lastChild.removeChild(layerRoot.lastChild.firstChild);<br>    
                
        
}<br>            
                
layerRoot.removeChild(layerRoot.lastChild);    
<br>                
        }<br><br>Thanks for taking the time to 
consider my questions,<br><br>elshae<br><br>
<div class="gmail_quote">On Tue, Oct 19, 2010 at 4:17 PM, IT Intern <span dir="ltr">&lt;<a href="mailto:itintern12@gmail.com" target="_blank">itintern12@gmail.com</a>&gt;</span> 
wrote:<br>
<blockquote class="gmail_quote" style="padding-left: 1ex; margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204);">Hello 
  GeoExt Friends,<br><br>So I have been using the GeoExt and Ext libraries to 
  develop my map browser and now there&#39;s a feature I&#39;d like to have, but don&#39;t 
  know how to go about it :)<br><br>So far everything is working.  What I 
  have is a tree panel that when a menu is clicked a parent node with layer 
  containers is added to the tree.  The layers in these containers are in 
  different languages, so as the user toggles between the languages in the menu, 
  it be nice if the layers in the previous language correspond to the language 
  that is currently selected.  I hope you will understand what I am asking 
  to do.  I guess a good starting point would be, is there a way to &quot;get&quot; 
  which layers are selected in a layer container?  Thanks for your time, 
  below is some relevant code:<br><br>//So there are many layers, one each per 
  language...<br><br>var chn_townships = new 
  OpenLayers.Layer.WMS(<br>                    
          &quot;Townships (Chinese trans)&quot;, &quot;<a href="http://localhost:8080/geoserver/wms" target="_blank">http://localhost:8080/geoserver/wms</a>&quot;, {layers: 
  &#39;cite:chn_townships&#39;, transparent: true}, {isBaseLayer: false, 
  displayInLayerSwitcher: true, visibility: 
  false}<br>               
          );<br>    
                  
  <br>            var tib_townships 
  = new 
  OpenLayers.Layer.WMS(<br>                    
          &quot;Townships (Tibetan trans)&quot;, &quot;<a href="http://localhost:8080/geoserver/wms" target="_blank">http://localhost:8080/geoserver/wms</a>&quot;, {layers: 
  &#39;cite:tib_townships&#39;, transparent: true}, {isBaseLayer: false, 
  displayInLayerSwitcher: true, visibility: true} 
  <br>               
          );  <br><br>//The layers are stored 
  in layer stores...<br>var tibLands = new 
  GeoExt.data.LayerStore({<br>        
          map: map,<br>    
              initDir: 
  0,<br>            
      layers: [tib_villages, tib_townships, tib_farms, 
  tib_countys]<br>            
  });<br><br>            var 
  chnLands = new GeoExt.data.LayerStore({<br>    
              map: 
  map,<br>            
      initDir: 0,<br>        
          layers: [chn_villages, chn_townships, 
  chn_farms, chn_countys]<br>        
      });<br><br>//Menu for users to select language<br>var 
  languageMenu = new Ext.menu.Menu({<br>        
          id: 
  &#39;mainMenu&#39;,<br>        
          style: {<br>    
      
              overflow: 
  &#39;visible&#39;     // For the Combo popup<br>    
              
  },<br>        
          items: [<br>    
                  // 
  A Field in a Menu<br>        
              
  {<br>        
                  
  text: &#39;Chinese&#39;,<br>        
                  
  checked: 
  false,<br>                        
  group: 
  &#39;theme&#39;,<br>                        
  icon: 
  &#39;./gif/cn.gif&#39;,<br>                       
      handler: checkHandler<br>    
      
              
  },{<br>        
                  
  text: &#39;English&#39;,<br>        
                  
  checked: 
  true,<br>                        
  group: 
  &#39;theme&#39;,<br>                        
  handler: checkHandler<br>        
              
  },{<br>        
                  
  text: &#39;Tibetan&#39;,<br>        
                  
  checked: 
  false,<br>                        
  group: 
  &#39;theme&#39;,<br>                        
  handler: checkHandler<br>        
                  
  }<br>        
          ]<br>    
          });<br><br>//The handler function that 
  listens to the users selection on the menu (This is where I want the magic to 
  happen ;)<br>function checkHandler(item, checked) 
  {<br>            
          var tibetContainer, 
  chineseContainer;<br>        
              
  <br>            
          if(item.text == 
  &#39;Tibetan&#39;){<br>            
              if(<a href="http://layerRoot.lastChild.id" target="_blank">layerRoot.lastChild.id</a> 
  == &#39;chinese&#39;){<br>        
                  
      
  layerRoot.removeChild(layerRoot.lastChild);    
  <br>            
              
  }<br>            
              
  <br>            
              tibetContainer = new 
  Ext.tree.TreeNode({<br>        
                  
      text: &quot;Tibetan Labels&quot;,<br>    
                  
          expanded: true,<br>    
                  
          id: &#39;tibet&#39;<br>    
                  
      });<br><br>        
                  
  tibetContainer.appendChild(new 
  GeoExt.tree.OverlayLayerContainer({<br>        
                  
      text: &quot;Lands (Tibetan trans)&quot;,<br>    
                  
          layerStore: 
  tibLands,<br>            
                  
  expanded: false,<br>            
                  
  loader: {param: &quot;LAYERS&quot;}<br>        
                  
  }));<br><br>            
              
  tibetContainer.appendChild(new 
  GeoExt.tree.OverlayLayerContainer({<br>        
                  
      text: &quot;Natural Selection (Tibetan 
  trans)&quot;,<br>            
                  
  layerStore: tibNaturalLayers,<br>        
                  
      expanded: false,<br>        
                  
      loader: {param: &quot;LAYERS&quot;}<br>    
                  
      }));<br><br>        
                  
  tibetContainer.appendChild(new 
  GeoExt.tree.OverlayLayerContainer({<br>        
                  
      text: &quot;Points of Interest (Tibetan 
  trans)&quot;,<br>            
                  
  layerStore: tibPointOfInterest,<br>        
                  
      expanded: false,<br>        
                  
      loader: {param: &quot;LAYERS&quot;}<br>    
                  
      }));<br><br>        
                  
  layerRoot.appendChild(tibetContainer);<br><br>    
                  
  }<br>            
          else if(item.text == 
  &#39;Chinese&#39;){<br>            
              
  <br>            
              chineseContainer = 
  new Ext.tree.TreeNode({<br>        
                  
      text: &quot;Chinese Labels&quot;,<br>    
                  
          expanded: true,<br>    
                  
          id: &#39;chinese&#39;<br>    
                  
      });<br><br>        
                  
  chineseContainer.appendChild(new 
  GeoExt.tree.OverlayLayerContainer({<br>        
                  
      text: &quot;Lands (Chinese trans)&quot;,<br>    
                  
          layerStore: 
  chnLands,<br>            
                  
  expanded: false,<br>            
                  
  loader: {param: &quot;LAYERS&quot;}<br>        
                  
  }));<br><br>            
              
  chineseContainer.appendChild(new 
  GeoExt.tree.OverlayLayerContainer({<br>        
                  
      text: &quot;Natural Selection (Chinese 
  trans)&quot;,<br>            
                  
  layerStore: chnNaturalLayers,<br>        
                  
      expanded: false,<br>        
                  
      loader: {param: &quot;LAYERS&quot;}<br>    
                  
      }));<br><br>        
                  
  chineseContainer.appendChild(new 
  GeoExt.tree.OverlayLayerContainer({<br>        
                  
      text: &quot;Points of Interest (Chinese 
  trans)&quot;,<br>            
                  
  layerStore: chnPointOfInterest,<br>        
                  
      expanded: false,<br>        
                  
      loader: {param: &quot;LAYERS&quot;}<br>    
                  
      }));<br><br>        
                  
  if(<a href="http://layerRoot.lastChild.id" target="_blank">layerRoot.lastChild.id</a> == 
  &#39;tibet&#39;){<br>            
                  
  //layerRoot.removeChild(layerRoot.lastChild);    
  <br>            
                  
  layerRoot.replaceChild(chineseContainer, layerRoot.lastChild)  //thought 
  this might have done it, this just replaces the nodes but not the layers 
  selected to the new ones :(<br>        
                  
  }else<br>            
              
  {layerRoot.appendChild(chineseContainer);}<br><br>    
                  
  }<br></blockquote></div><br>
</div></div><p>
</p><hr>

<p></p>_______________________________________________<br>Users mailing 
list<br><a href="mailto:Users@geoext.org" target="_blank">Users@geoext.org</a><br><a href="http://www.geoext.org/cgi-bin/mailman/listinfo/users" target="_blank">http://www.geoext.org/cgi-bin/mailman/listinfo/users</a><br>
</div>
</blockquote></div><br>