No problem.
You could also append TreeNodes to a TreeNode and create a nested -
folder tree - kind of look.....
Create the root of your tree:
//
var layerRoot = new Ext.tree.TreeNode({
text: "Layers"
});
//
And create a branch, with another TreeNode:
//
var blayerBranch = new Ext.tree.TreeNode({
text: "B Layers"
});
//
Then append children to the branch:
//
blayerBranch.appendChild(new GeoExt.tree.LayerContainer({
text: "County B layers",
map: mapPanel,
loader: {
filter: function(record) {
var myarr = new Array();
myarr[0]=record.get("layer").name.indexOf("County");
myarr[1]=record.get("layer").name.indexOf("Balance");
if(myarr[0]!==-1 && myarr[1]!==-1){
return true;
}else{
return false;
}
}
}
}));
//
keep on appending children to that branch..... or create other branches
and add children to those branches....
Then append the branches to the root:
//
layerRoot.appendChild(blayerBranch);
// if you made more branches add them in the same manner, like
'layerRoot.appendChild(clayerBranch);' for a branch called clayerBranch...
//
Then add the root to the TreePanel with the "root:" paramater:
//
var tree = new Ext.tree.TreePanel({
region: "west",
frame: false,
title: "Table of Contents",
root: layerRoot,
});
//
On 9/1/2010 11:08 AM, Andrew Stewart wrote:
Trying to find a good example on how to add multiple LayerContainers
to my TreePanel but so far unsuccesful.
I've defined two LayerContainer controls like so -
var layerList_Labels = new GeoExt.tree.LayerContainer({
text: 'Labels',
layerStore: mapPanel.layers,
leaf: false,
expanded: false,
loader:
{
filter: function(record)
{
var myarr = new Array();
myarr[0] = record.get("layer").name.indexOf("Overview Streets");
myarr[1] = record.get("layer").name.indexOf("Quadrant Streets");
if(myarr[0]==-1 && myarr[1]==-1)
{
return false;
}
else
{
return true;
}
}
}
});
var layerList_Labels2 = new GeoExt.tree.LayerContainer({
text: 'Labels2',
layerStore: mapPanel.layers,
leaf: false,
expanded: false,
loader:
{
filter: function(record)
{
var myarr = new Array();
myarr[0] = record.get("layer").name.indexOf("Overview Streets");
myarr[1] = record.get("layer").name.indexOf("Quadrant Streets");
if(myarr[0]==-1 && myarr[1]==-1)
{
return false;
}
else
{
return true;
}
}
}
});
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.
var layerTree = new Ext.tree.TreePanel({
title: '',
renderTo: 'legend',
root: layerList_Labels,
enableDD: true,
applyLoader: true
});
------------------------------------------------------------------------
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.
_______________________________________________
Users mailing list
[email protected]
http://www.geoext.org/cgi-bin/mailman/listinfo/users
--
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
[email protected]
_______________________________________________
Users mailing list
[email protected]
http://www.geoext.org/cgi-bin/mailman/listinfo/users