<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
No problem. <br>
You could also append TreeNodes to a TreeNode and create a nested -
folder tree - kind of look.....<br>
<br>
Create the root of your tree:<br>
//<br>
var layerRoot = new Ext.tree.TreeNode({<br>
text: "Layers"<br>
});<br>
//<br>
And create a branch, with another TreeNode:<br>
//<br>
var blayerBranch = new Ext.tree.TreeNode({<br>
text: "B Layers"<br>
});<br>
//<br>
Then append children to the branch:<br>
//<br>
blayerBranch.appendChild(new GeoExt.tree.LayerContainer({<br>
text: "County B layers",<br>
map: mapPanel,<br>
loader: {<br>
filter: function(record) {<br>
var myarr = new Array();<br>
myarr[0]=record.get("layer").name.indexOf("County");<br>
myarr[1]=record.get("layer").name.indexOf("Balance");<br>
<br>
if(myarr[0]!==-1 &&
myarr[1]!==-1){<br>
return true;<br>
}else{<br>
return false;<br>
}<br>
}<br>
}<br>
}));<br>
//<br>
keep on appending children to that branch..... or create other branches
and add children to those branches....<br>
Then append the branches to the root:<br>
//<br>
layerRoot.appendChild(blayerBranch);<br>
<br>
// if you made more branches add them in the same manner, like
'layerRoot.appendChild(clayerBranch);' for a branch called
clayerBranch...<br>
<br>
//<br>
Then add the root to the TreePanel with the "root:" paramater:<br>
//<br>
var tree = new Ext.tree.TreePanel({<br>
region: "west",<br>
frame: false,<br>
title: "Table of Contents",<br>
root: layerRoot,<br>
}); <br>
//<br>
<br>
On 9/1/2010 11:08 AM, Andrew Stewart wrote:
<blockquote
cite="mid:94816848A8EB3941B1E8592F425827A96845C804A9@chex2.crdnet.ca"
type="cite">
<title></title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
<meta name="GENERATOR" content="MSHTML 8.00.6001.18939">
<div dir="ltr" align="left"><font face="Arial" size="2"><span
class="102160316-01092010">Trying to find a good example on how to add
multiple LayerContainers to my TreePanel but so far unsuccesful.</span></font></div>
<div> </div>
<div><span class="102160316-01092010"><font face="Arial" size="2">I've
defined two LayerContainer controls like so -</font></span></div>
<!-- Converted from text/rtf format --><font color="#008000" size="2"><font
color="#008000" size="2"></font></font>
<p><font color="#008000" size="2"><font color="#008000" size="2"><br>
</font></font><font color="#0000ff" size="2"><font color="#0000ff"
size="2">var</font></font><font size="2"> layerList_Labels = </font><font
color="#0000ff" size="2"><font color="#0000ff" size="2">new</font></font><font
size="2"> GeoExt.tree.LayerContainer({<br>
text: </font><font color="#a31515" size="2"><font color="#a31515"
size="2">'Labels'</font></font><font size="2">,<br>
layerStore: mapPanel.layers,<br>
leaf: </font><font color="#0000ff" size="2"><font color="#0000ff"
size="2">false</font></font><font size="2">,<br>
expanded: </font><font color="#0000ff" size="2"><font color="#0000ff"
size="2">false</font></font><font size="2">,<br>
loader: <br>
{<br>
filter: </font><font color="#0000ff" size="2"><font color="#0000ff"
size="2">function</font></font><font size="2">(record) <br>
{<br>
</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">var</font></font><font
size="2"> myarr = </font><font color="#0000ff" size="2"><font
color="#0000ff" size="2">new</font></font><font size="2"> Array();<br>
myarr[0] = record.</font><font color="#0000ff" size="2"><font
color="#0000ff" size="2">get</font></font><font size="2">(</font><font
color="#a31515" size="2"><font color="#a31515" size="2">"layer"</font></font><font
size="2">).name.indexOf(</font><font color="#a31515" size="2"><font
color="#a31515" size="2">"Overview Streets"</font></font><font size="2">);<br>
myarr[1] = record.</font><font color="#0000ff" size="2"><font
color="#0000ff" size="2">get</font></font><font size="2">(</font><font
color="#a31515" size="2"><font color="#a31515" size="2">"layer"</font></font><font
size="2">).name.indexOf(</font><font color="#a31515" size="2"><font
color="#a31515" size="2">"Quadrant Streets"</font></font><font size="2">);<br>
</font><font color="#0000ff" size="2"><font color="#0000ff" size="2">if</font></font><font
size="2">(myarr[0]==-1 && myarr[1]==-1)<br>
{<br>
</font><font size="2"><font color="#0000ff"><span
class="102160316-01092010">r</span>eturn</font> <font color="#0000ff"><font
color="#0000ff">false</font></font>;<br>
</font><font size="2">}<br>
</font><font color="#0000ff"><font color="#0000ff"><font size="2">else<br>
</font></font></font><font size="2">{<br>
</font><font size="2"><font color="#0000ff"><font color="#0000ff">return</font></font>
<font color="#0000ff"><font color="#0000ff">true</font></font>;<br>
</font><font size="2">}<br>
</font><font size="2">}<br>
</font><font size="2">}<br>
</font><font size="2">});</font></p>
<p><br>
<font size="2"><font color="#0000ff"><font color="#0000ff">var</font></font>
layerList_Labels<span class="102160316-01092010">2</span> = <font
color="#0000ff"><font color="#0000ff">new</font></font>
GeoExt.tree.LayerContainer({<br>
text: <font color="#a31515">'Labels<span class="102160316-01092010">2</span>'</font>,<br>
layerStore: mapPanel.layers,<br>
leaf: <font color="#0000ff"><font color="#0000ff">false</font></font>,<br>
expanded: <font color="#0000ff"><font color="#0000ff">false</font></font>,<br>
loader: <br>
{<br>
filter: <font color="#0000ff"><font color="#0000ff">function</font></font>(record)
<br>
{<br>
<font color="#0000ff"><font color="#0000ff">var</font></font> myarr =
<font color="#0000ff"><font color="#0000ff">new</font></font> Array();<br>
myarr[0] = record.<font color="#0000ff"><font color="#0000ff">get</font></font>(<font
color="#a31515"><font color="#a31515">"layer"</font></font>).name.indexOf(<font
color="#a31515"><font color="#a31515">"Overview Streets"</font></font>);<br>
myarr[1] = record.<font color="#0000ff"><font color="#0000ff">get</font></font>(<font
color="#a31515"><font color="#a31515">"layer"</font></font>).name.indexOf(<font
color="#a31515"><font color="#a31515">"Quadrant Streets"</font></font>);<br>
<font color="#0000ff"><font color="#0000ff">if</font></font>(myarr[0]==-1
&& myarr[1]==-1)<br>
{<br>
<font color="#0000ff"><span class="102160316-01092010">r</span>eturn</font>
<font color="#0000ff"><font color="#0000ff">false</font></font>;<br>
}<br>
</font><font color="#0000ff"><font color="#0000ff"><font size="2">else<br>
</font></font></font><font size="2">{<br>
</font><font size="2"><font color="#0000ff"><font color="#0000ff">return</font></font>
<font color="#0000ff"><font color="#0000ff">true</font></font>;<br>
</font><font size="2">}<br>
</font><font size="2">}<br>
</font><font size="2">}<br>
</font><font size="2">});</font></p>
<p><span class="102160316-01092010"><font color="#0000ff" face="Arial">Now
I am just unsure exactly how to add these both to my TreePanel - i've
tried adding them both to root, or trying to use children but it is not
showing up. Any help greatly appreciated.</font></span></p>
<span class="102160316-01092010"><font size="2"></font>
<p><font color="#0000ff" size="2"><font color="#0000ff" size="2">var</font></font><font
size="2"> layerTree = </font><font color="#0000ff" size="2"><font
color="#0000ff" size="2">new</font></font><font size="2">
Ext.tree.TreePanel({<br>
title: </font><font color="#a31515" size="2"><font color="#a31515"
size="2">''</font></font><font size="2">,<br>
renderTo: </font><font color="#a31515" size="2"><font color="#a31515"
size="2">'legend'</font></font><font size="2">,<br>
root: layerList_Labels,<br>
enableDD: </font><font color="#0000ff" size="2"><font color="#0000ff"
size="2">true</font></font><font size="2">,<br>
applyLoader: </font><font color="#0000ff" size="2"><font
color="#0000ff" size="2">true<br>
</font></font><font size="2">});</font></p>
</span>
<div>
<hr>This e-mail is intended for the original recipient(s) only. If
you have received it in error, please advise the sender and delete this
message.
</div>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@geoext.org">Users@geoext.org</a>
<a class="moz-txt-link-freetext" href="http://www.geoext.org/cgi-bin/mailman/listinfo/users">http://www.geoext.org/cgi-bin/mailman/listinfo/users</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">--
Ryan Williams, GISP
GIS Analyst / Programmer
PAQ Interactive Inc.
107 S State St., Suite 300
Monticello, IL 61856-1968
Office: (217) 762-7955
Mobile: (217) 722-2794
<a class="moz-txt-link-abbreviated" href="mailto:rwilliams@paqinteractive.com">rwilliams@paqinteractive.com</a></pre>
</body>
</html>