<!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">
The way I did it was to first add a TreeNode:<br>
//<br>
var layerRoot = new Ext.tree.TreeNode({<br>
text: "Layers",<br>
expanded: true<br>
});<br>
//<br>
then add children to that:<br>
//<br>
layerRoot.appendChild(new GeoExt.tree.LayerContainer({<br>
text: "Overlays",<br>
map: mapPanel,<br>
expanded: true,<br>
singleClickExpand: true,<br>
loader: { <br>
filter: function(record) {<br>
var myarr = new Array();<br>
myarr[0]=record.get("layer").name.indexOf("Balance");<br>
myarr[1]=record.get("layer").name.indexOf("Ratio");<br>
myarr[2]=record.get("layer").name.indexOf("Highlight");<br>
<br>
if(myarr[0]==-1 && myarr[1]==-1
&& myarr[2]==-1){<br>
return true;<br>
}else{<br>
return false;<br>
}<br>
}<br>
} <br>
}));<br>
<br>
//<br>
You can keep appending children by repeating the above, edited to hold
the layers you want. <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>
enableDD: true,<br>
collapsible: true,<br>
height: "60%",<br>
expanded: true,<br>
autoScroll: true<br>
});<br>
<br>
//<br>
<br>
<br>
Ryan<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>