TOC checkbox: automatically check parent when clicking sublayer

3770
6
04-13-2010 12:29 AM
ManuelFrias
New Contributor III
Hi,

Imagine all layers being off when opening the viewer. There are several parent layers containing sublayers. When someone selects a sublayer in TOC the parent layer does not get selected automatically. The user is therefore forced to click on both the sublayer AND the parent to view the layer.

Is this the default behavior of the sample viewer? Has anyone come up any way to solve it?

Tahnks,
Manolo
Tags (2)
0 Kudos
6 Replies
JamesHolstead
New Contributor
This works just for the immediate parent. If it is nested you would write a method and recursively set all parent's visble to true.

TocItemRenderer.as:

               private function onCheckBoxClick( event:MouseEvent ):void
     {
      event.stopPropagation();
      
      if (data is TocItem) {
    var item:TocItem = TocItem(data);
    
    item.visible = _checkbox.selected;
                                if(item.visible == true && item.parent.visible == false)
     item.parent.visible = true;      }
  }
0 Kudos
ManuelFrias
New Contributor III
Good suggestion,

it didn't work for me though 😞
Every group layer in my application is a map service. I guess that's the problem.

Thanks anyway!
Manolo
0 Kudos
DavidGalluzzo
New Contributor
Manolo,

I did a rewrite of the TOC classes to change the way they work with group layers. Currently when you turn on a group layer, it turns on all sub layers. This does not work for me as some of my group layers contain lots of sub layers. My code will turn on the parent of the group layer when a sub layer is turned on but in will not turn on the main map service. I am not sure how it will work if the group layers are services but you can give it a try. I had to make changes to all the classes in the TOCClasses folder. I suggest saving the original classes before trying this code.
0 Kudos
AshleyOwens
New Contributor II
Thank you for the attached classes, they have been very helpful!
Question:  what is the location of the compiled .as code? I would like to deploy this change to another server, and I don't know where the compiled version of the tocclasses is...
0 Kudos
tanyabisen
New Contributor
Hi mfrias,

I tried using your TOC classes.. but i cant find CheckBoxIndeterminate and mapUtil...can you please tell the exact source so that I can refer to it.

Thanks.
Tanya
0 Kudos
btpbtp
by
New Contributor II

Hello,

is there any solution for that problem in the web appbuilder layer list widget?

thanks.

0 Kudos