Select to view content in your preferred language

change toc style

545
2
03-11-2013 02:06 PM
RinatSolorzano_Palero
Deactivated User
HI everyone,

i would appreciate so much your help with this particular topic, i want to make a little change in TOC's widget so when i expand a group layer, all others should collapse in every case, and the title of the group that has been expanded change in someway that can be different from other group titles....

thaks in advance!!!!

Rinat S.
Tags (2)
0 Kudos
2 Replies
DougBrowning
MVP Esteemed Contributor
I had something similar where I wanted to expand the last thing added. 

You can use toc.expandItem(toc.dataProvider.source,true,true,true,null);  where in your case the toc.dataProvider.source part would be the item you want to expand.

The real trick for me was that after using toc.expandItem make sure to run toc.validateNow(); or nothing will happen.

I thought there is a toc.collapseall or something like that but I can not find it.  I found in mine that when something is added it collapses all of them anyways.  The command toc.validateNow(); could make that happen.



If you have a link to the item (the toc.dataProvider.source) above you can also change its font I think.  There is code in there that changes the font for scale dependencies so maybe look for that.  Check TocMapLayerItem.mxml.

Hope that helps.
0 Kudos
RinatSolorzano_Palero
Deactivated User
I had something similar where I wanted to expand the last thing added. 

You can use toc.expandItem(toc.dataProvider.source,true,true,true,null);  where in your case the toc.dataProvider.source part would be the item you want to expand.

The real trick for me was that after using toc.expandItem make sure to run toc.validateNow(); or nothing will happen.

I thought there is a toc.collapseall or something like that but I can not find it.  I found in mine that when something is added it collapses all of them anyways.  The command toc.validateNow(); could make that happen.



If you have a link to the item (the toc.dataProvider.source) above you can also change its font I think.  There is code in there that changes the font for scale dependencies so maybe look for that.  Check TocMapLayerItem.mxml.

Hope that helps.



Thnks a lot...

as the problem was in the expand function i had to override and modify it this way (TOC.as):

override public function expandItem(item:Object, open:Boolean,
           animate:Boolean = false,
           dispatchEvent:Boolean = false,   
           cause:Event = null):void {
     
   if (open&&!getParentItem(item)){
   
   
    var tocItem:TocMapLayerItem
    var tocItem2:TocMapLayerItem
    var tocItemRend:TocItemRenderer
   
    tocItem=TocMapLayerItem(item);
   
   
   
    if (obj_aux){
     tocItem2=TocMapLayerItem(obj_aux);
     tocItem2.label=lab_aux;
     if (rend_aux){
      rend_aux.font_out();
     }
    }
    obj_aux=item;
    lab_aux=tocItem.label
    
    if (this.itemToItemRenderer(item)){
     rend_aux=TocItemRenderer(this.itemToItemRenderer(item))
     tocItemRend=TocItemRenderer(this.itemToItemRenderer(item))
     tocItemRend.font_change();
    }
    tocItem.label=tocItem.label.toUpperCase();
   
   
    if (!getParentItem(item)&&!isItemOpen(item)){
   
     for each (var item2:Object in this.dataProvider){
     
      if (item!=item2){
       this.expandItem(item2, false);
      }
     
     }
    }
   }

   super.expandItem(item,open,animate, dispatchEvent,cause)
  
  
  
  }

TOC was using expanItem to expand and collapse all objects so as you said, that was the key....

I use auxiliary items to restore default values once the menu is not selected anymore ant font_change() and font_out() are some glow and title effects

public function font_change():void
  {
   var glow:GlowFilter = new GlowFilter();
   glow.color = 0x0508AA //0x89B2DB//0x009922;
   glow.alpha = 1;
   glow.strength=1;

   label.filters=[glow]
  
  }

Rinat S.
0 Kudos