[Users] Question on adding multiple layercontainer to TreePanel

Andrew Stewart Andrew.Stewart at reddeer.ca
Wed Sep 1 18:38:41 CEST 2010


Thanks again, you have been really quite helpful , I would be traversing confusing examples without your assistance, I definitely owe ya!


________________________________
From: users-bounces at geoext.org [mailto:users-bounces at geoext.org] On Behalf Of Ryan Williams
Sent: September 01, 2010 10:30 AM
To: users at geoext.org
Subject: Re: [Users] Question on adding multiple layercontainer to TreePanel

The way I did it was to first add a TreeNode:
//
     var layerRoot = new Ext.tree.TreeNode({
                text: "Layers",
                expanded: true
            });
//
then add children to that:
//
    layerRoot.appendChild(new GeoExt.tree.LayerContainer({
                text: "Overlays",
                map: mapPanel,
                expanded: true,
                singleClickExpand: true,
                loader: {
                            filter: function(record) {
                                var myarr = new Array();
                                myarr[0]=record.get("layer").name.indexOf("Balance");
                                myarr[1]=record.get("layer").name.indexOf("Ratio");
                                myarr[2]=record.get("layer").name.indexOf("Highlight");

                                if(myarr[0]==-1 && myarr[1]==-1 && myarr[2]==-1){
                                    return true;
                                }else{
                                    return false;
                                }
                            }
                        }
            }));

//
You can keep appending children by repeating the above, edited to hold the layers you want.

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,
                enableDD: true,
                collapsible: true,
                height: "60%",
                expanded: true,
                autoScroll: true
            });

//


Ryan

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
Users at geoext.org<mailto:Users at geoext.org>
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
rwilliams at paqinteractive.com<mailto:rwilliams at paqinteractive.com>

________________________________
[This message has been scanned for security content threats and viruses.]

[The City of Red Deer I.T. Services asks that you please consider the environment before printing this e-mail.]



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20100901/bdc8acb4/attachment-0001.htm 


More information about the Users mailing list