[Users] Question on adding multiple layercontainer to TreePanel

Ryan Williams rwilliams at paqinteractive.com
Wed Sep 1 18:29:38 CEST 2010


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
> 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

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


More information about the Users mailing list