<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content=text/html;charset=iso-8859-1>
<META content="MSHTML 6.00.6002.18309" name=GENERATOR></HEAD>
<BODY id=MailContainerBody
style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-TOP: 15px" leftMargin=0
topMargin=0 CanvasTabStop="true" 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 & 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">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">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">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">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: #f5f5f5">
<DIV style="font-color: black"><B>From:</B> <A title=itintern12@gmail.com
href="mailto:itintern12@gmail.com">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">users@geoext.org</A> </DIV>
<DIV><B>Subject:</B> Re: [Users] Keeping Selected Layers When Replacing Child
Nodes</DIV></DIV></DIV>
<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'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 <
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><<A
href="mailto:itintern12@gmail.com">itintern12@gmail.com</A>></SPAN>
wrote:<BR>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">Hello
GeoExt Friends,<BR><BR>So I have been using the GeoExt and Ext libraries to
develop my map browser and now there's a feature I'd like to have, but don'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 "get"
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>
"Townships (Chinese trans)", "<A
href="http://localhost:8080/geoserver/wms"
target=_blank>http://localhost:8080/geoserver/wms</A>", {layers:
'cite:chn_townships', transparent: true}, {isBaseLayer: false,
displayInLayerSwitcher: true, visibility:
false}<BR>
);<BR>
<BR> var tib_townships
= new
OpenLayers.Layer.WMS(<BR>
"Townships (Tibetan trans)", "<A
href="http://localhost:8080/geoserver/wms"
target=_blank>http://localhost:8080/geoserver/wms</A>", {layers:
'cite:tib_townships', 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:
'mainMenu',<BR>
style: {<BR>
overflow:
'visible' // For the Combo popup<BR>
},<BR>
items: [<BR>
//
A Field in a Menu<BR>
{<BR>
text: 'Chinese',<BR>
checked:
false,<BR>
group:
'theme',<BR>
icon:
'./gif/cn.gif',<BR>
handler: checkHandler<BR>
},{<BR>
text: 'English',<BR>
checked:
true,<BR>
group:
'theme',<BR>
handler: checkHandler<BR>
},{<BR>
text: 'Tibetan',<BR>
checked:
false,<BR>
group:
'theme',<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 ==
'Tibetan'){<BR>
if(<A
href="http://layerRoot.lastChild.id" target=_blank>layerRoot.lastChild.id</A>
== 'chinese'){<BR>
layerRoot.removeChild(layerRoot.lastChild);
<BR>
}<BR>
<BR>
tibetContainer = new
Ext.tree.TreeNode({<BR>
text: "Tibetan Labels",<BR>
expanded: true,<BR>
id: 'tibet'<BR>
});<BR><BR>
tibetContainer.appendChild(new
GeoExt.tree.OverlayLayerContainer({<BR>
text: "Lands (Tibetan trans)",<BR>
layerStore:
tibLands,<BR>
expanded: false,<BR>
loader: {param: "LAYERS"}<BR>
}));<BR><BR>
tibetContainer.appendChild(new
GeoExt.tree.OverlayLayerContainer({<BR>
text: "Natural Selection (Tibetan
trans)",<BR>
layerStore: tibNaturalLayers,<BR>
expanded: false,<BR>
loader: {param: "LAYERS"}<BR>
}));<BR><BR>
tibetContainer.appendChild(new
GeoExt.tree.OverlayLayerContainer({<BR>
text: "Points of Interest (Tibetan
trans)",<BR>
layerStore: tibPointOfInterest,<BR>
expanded: false,<BR>
loader: {param: "LAYERS"}<BR>
}));<BR><BR>
layerRoot.appendChild(tibetContainer);<BR><BR>
}<BR>
else if(item.text ==
'Chinese'){<BR>
<BR>
chineseContainer =
new Ext.tree.TreeNode({<BR>
text: "Chinese Labels",<BR>
expanded: true,<BR>
id: 'chinese'<BR>
});<BR><BR>
chineseContainer.appendChild(new
GeoExt.tree.OverlayLayerContainer({<BR>
text: "Lands (Chinese trans)",<BR>
layerStore:
chnLands,<BR>
expanded: false,<BR>
loader: {param: "LAYERS"}<BR>
}));<BR><BR>
chineseContainer.appendChild(new
GeoExt.tree.OverlayLayerContainer({<BR>
text: "Natural Selection (Chinese
trans)",<BR>
layerStore: chnNaturalLayers,<BR>
expanded: false,<BR>
loader: {param: "LAYERS"}<BR>
}));<BR><BR>
chineseContainer.appendChild(new
GeoExt.tree.OverlayLayerContainer({<BR>
text: "Points of Interest (Chinese
trans)",<BR>
layerStore: chnPointOfInterest,<BR>
expanded: false,<BR>
loader: {param: "LAYERS"}<BR>
}));<BR><BR>
if(<A href="http://layerRoot.lastChild.id"
target=_blank>layerRoot.lastChild.id</A> ==
'tibet'){<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>
<P>
<HR>
<P></P>_______________________________________________<BR>Users mailing
list<BR>Users@geoext.org<BR>http://www.geoext.org/cgi-bin/mailman/listinfo/users<BR></BODY></HTML>