Select to view content in your preferred language

TOC Widget - how to default open all layers so that legend shows

856
3
Jump to solution
03-14-2012 11:53 AM
GeorgiannaStrode
Deactivated User
With the TOCWidget, I'd like for EVERYTHING to be open when the widget opens (the equivalent of clicking 'Expand All'). 

I already have:
<expanded>true</expanded>
in the TOCWidget.xml and this works to open the mapservice to show the individual layers.  But I'd like to have the individual layers open so that the legends show.

Is there a way to do this?

Thanks!
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus
Georgianna,

   Sure it is a pretty easy code change in the TOC.as
Add this new function:
        private function expandAll(item:TocItem):void         {             item.collapsed = false;             expandChildrenOf(item, true);             if(item.isGroupLayer()){                 for each (var item2:TocItem in item.children){                     expandAll(item2);                 }             }         }


Search for this line in the the TOC.as and comment it out and add this new line:
                //if(_expanded) expandItem(tocItem, true, true, false, null);                 if(_expanded) expandAll(tocItem);


That's it.

Don't forget to click the Mark as answer check and to click the top arrow (promote) as shown below:

View solution in original post

0 Kudos
3 Replies
RobertScheitlin__GISP
MVP Emeritus
Georgianna,

   Sure it is a pretty easy code change in the TOC.as
Add this new function:
        private function expandAll(item:TocItem):void         {             item.collapsed = false;             expandChildrenOf(item, true);             if(item.isGroupLayer()){                 for each (var item2:TocItem in item.children){                     expandAll(item2);                 }             }         }


Search for this line in the the TOC.as and comment it out and add this new line:
                //if(_expanded) expandItem(tocItem, true, true, false, null);                 if(_expanded) expandAll(tocItem);


That's it.

Don't forget to click the Mark as answer check and to click the top arrow (promote) as shown below:
0 Kudos
GeorgiannaStrode
Deactivated User
Robert, you're the best!  Huge thanks.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Georgianna,

   FYI, you always need to put the make the green check mark appear on the thread that answers your question. As it stands right now you marked your thread as the answer and I am not receiving points for answering your question, you are receiving the credit.
0 Kudos