Collapse all layers at start in agsjs.dijit.TOC

7408
15
09-06-2012 02:06 AM
ChristianLutz
New Contributor III
Hi all,

I am using this TOC http://gmaps-utility-gis.googlecode.com/svn-history/r354/trunk/agsjs/docs/toc/examples.html
Could someone tell me how to collapse ALL LAYERS at start or give me a hint?

Thanks a lot!!
0 Kudos
15 Replies
AdrianMarsden
Occasional Contributor III
Hi - I'm working on the same problem, selectively collapse/expand at start up.  Ive added an extra parameter to the definition -

            {
                layer: altmaps,
                slider: true,
                title: "OS Basemaps",
                isopen: false
            }


Now just need to know how to collapse a node from within the (excellent) code!

Cheers

ACM
0 Kudos
AdrianMarsden
Occasional Contributor III
ok - cracked the code to get all groups collapsed - as in screenshot

[ATTACH=CONFIG]18426[/ATTACH]

In the postcreate function find and alter as below

           if (this.data._subLayerInfos) {
                //acm added to collapse groups at the start
                this.toggler.hide()
                //end acm addition


and a bit later

           //ACM also changed this line to get groups initial expand set
                //dojo.addClass(this.iconNode, a ? "dijitTreeExpandoOpened" : "dijitTreeExpandoClosed")
                dojo.addClass(this.iconNode, a ? "dijitTreeExpandoClosed" : "dijitTreeExpandoClosed")



So far it appears to work.  The second part could be neater, but doing it this way you can see it has been changed to always return "dijitTreeExpandoClosed"

ACM
0 Kudos
NianweiLiu
Occasional Contributor II
use "collapsed: true" option for each layerInfo in constructor.

var toc = new agsjs.dijit.TOC({
                  map: map,
                  layerInfos: [{
                    layer: safety,
                    title: "Safety Operations",
                   collapsed: true
                  },{
                    layer: census,
                    title: "Census",
                   collapsed: true
                  }]
                }, 'tocDiv');
                toc.startup();


It's documented in the reference page and source code. search for "collapsed".
0 Kudos
AdrianMarsden
Occasional Contributor III
Many thanks, although tried that with my version headed "/*built on 2012-08-21 14:32:39.70*/" without any luck

ACM
0 Kudos
NianweiLiu
Occasional Contributor II
0 Kudos
DerekWicks1
New Contributor
Is there any way to have the map service layer initially expanded but all collapsible groups within the map service (unique value renderers and group layers) collapsed?
0 Kudos
NianweiLiu
Occasional Contributor II
Is there any way to have the map service layer initially expanded but all collapsible groups within the map service (unique value renderers and group layers) collapsed?


I'd suggest you create a enhancement request with the server, so it will return the exact expand/collapse information you set in the MXD. In that case, the TOC can basically reproduce what you configed in the MXD.
0 Kudos
RichardMoussopo
Occasional Contributor III

This method did not work for me!

0 Kudos
AbdulMateen
New Contributor
can you share clear code , what is "a" in dojo.addClass(this.iconNode, a ? "dijitTreeExpandoOpened" : "dijitTreeExpandoClosed")
                c


ok - cracked the code to get all groups collapsed - as in screenshot

[ATTACH=CONFIG]18426[/ATTACH]

In the postcreate function find and alter as below

           if (this.data._subLayerInfos) {
                //acm added to collapse groups at the start
                this.toggler.hide()
                //end acm addition


and a bit later

           //ACM also changed this line to get groups initial expand set
                //dojo.addClass(this.iconNode, a ? "dijitTreeExpandoOpened" : "dijitTreeExpandoClosed")
                c



So far it appears to work.  The second part could be neater, but doing it this way you can see it has been changed to always return "dijitTreeExpandoClosed"

ACM
0 Kudos