[Users] Question about turning on entire group of layers in layercontainer/treenode

Andreas Hocevar ahocevar at opengeo.org
Sun Sep 19 21:17:11 CEST 2010


Hi,

two things to do here:

 * configure the LayerContainer with checked: true
 * add a checkchange handler to the LayerContainer that walks through all its children and gives them the same checked state that the parent has.

Regards,
Andreas.

On Sep 17, 2010, at 17:37 , Andrew Stewart wrote:

> Sorry didn't realize it was pasted all messed up, here is the code a little more readable thanks
>  
>  
>  
>         //Labels LayerList 
>         var layerList_Labels = new GeoExt.tree.LayerContainer({
>         text: 'Labels',
>         layerStore: mapPanel.layers,
>         leaf: false,
>         cls: 'rootnode',
>         enableDD: true,
>         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");
>                 myarr[2] = record.get("layer").name.indexOf("Neighbourhood Streets");
>                 myarr[3] = record.get("layer").name.indexOf("Block Streets");
>                 myarr[4] = record.get("layer").name.indexOf("Proposed Streets");
>                 myarr[5] = record.get("layer").name.indexOf("Address Label (Overview)");
>                 myarr[6] = record.get("layer").name.indexOf("Address Label (Detail)");
>                 if(myarr[0]==-1 && myarr[1]==-1 && myarr[2]==-1 && myarr[3]==-1 && myarr[4]==-1 && myarr[5]==-1 && myarr[6]==-1)
>                 {
>                 return false;
>                 }
>                 else
>                 {
>                 return true;
>                 }
>             }
>             }
>         });
>  
> 
>         //declare root tree node
>         var layerRoot = new Ext.tree.TreeNode({
>             enableDD: true,
>             text: "All Legend Items",
>             expanded: true
>             });
>             
>        //add children to root node
>        layerRoot.appendChild(layerList_Labels)
>        layerRoot.appendChild(layerlist_AOI)
>        layerRoot.appendChild(layerlist_Trails)
>        layerRoot.appendChild(layerlist_Footprints)
>        layerRoot.appendChild(layerlist_LegalFabric)
>        layerRoot.appendChild(layerlist_ParcelFabric)
>        layerRoot.appendChild(layerlist_Base)
>        layerRoot.appendChild(layerlist_Orthos)
>               
>             
>         var layerTree = new Ext.tree.TreePanel({
>         title: '',
>         renderTo: 'legend',
>         root: layerRoot,
>         enableDD: true,
>         applyLoader: true,
>         rootVisible: false
>  
>  
> 
> From: Pol [mailto:d.paolino at gmail.com] 
> Sent: September 17, 2010 9:33 AM
> To: Andrew Stewart
> Subject: Re: [Users] Question about turning on entire group of layers in layercontainer/treenode
> 
> Dude,
> 
> Is it possible for you to indent your code ? It's really easier to read and to understand it...
> 
> Thanks !
> 
> -Pol D.-
> http://www.google.com/profiles/110003197662276240659
> 
> 
> On Fri, Sep 17, 2010 at 17:23, Andrew Stewart <Andrew.Stewart at reddeer.ca> wrote:
>  I have a layerlist that is working fine and being entered into a layercontainer/treepanel to show all my layers. Everything works fine but I am wondering if there is a way to turn on all layers by adding a checkbox to the group much like checkboxes are next to all individual layers I have. Appreciate any advice on how to modify my existing code to accomplish this so I can turn all my layers on by clicking the group (root layer) or if there is another way to do this, thanks.
> 
>  //Labels LayerList
> 
> 
> var layerList_Labels = new GeoExt.tree.LayerContainer({
> text:
> 
> 'Labels',
> layerStore: mapPanel.layers,
> 
> leaf:
> 
> false,
> cls:
> 
> 'rootnode',
> enableDD:
> 
> true,
> 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");
> myarr[2] = record.
> 
> get("layer").name.indexOf("Neighbourhood Streets");
> myarr[3] = record.
> 
> get("layer").name.indexOf("Block Streets");
> myarr[4] = record.
> 
> get("layer").name.indexOf("Proposed Streets");
> myarr[5] = record.
> 
> get("layer").name.indexOf("Address Label (Overview)");
> myarr[6] = record.
> 
> get("layer").name.indexOf("Address Label (Detail)");
> 
> if(myarr[0]==-1 && myarr[1]==-1 && myarr[2]==-1 && myarr[3]==-1 && myarr[4]==-1 && myarr[5]==-1 && myarr[6]==-1)
> {
> 
> 
> return false;
> }
> 
> 
> else
> {
> 
> 
> return true;
> }
> 
> }
> 
> }
> 
> });
> 
> 
> 
> //declare root tree node
> 
> var layerRoot = new Ext.tree.TreeNode({
> enableDD:
> 
> true,
> text:
> 
> "All Legend Items",
> expanded:
> 
> true
> });
> 
> 
> 
> //add children to root node
> layerRoot.appendChild(layerList_Labels)
> 
> 
> 
> 
> var layerTree = new Ext.tree.TreePanel({
> title:
> 
> '',
> renderTo:
> 
> 'legend',
> root: layerRoot,
> 
> enableDD:
> 
> true,
> applyLoader:
> 
> true,
> rootVisible:
> 
> false
> });
> 
> 
> 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
> 
> 
> 
> [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.]
> 
> 
> 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



-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.



More information about the Users mailing list