Event - Item selected (checkbox) in Table Of Content

531
1
10-18-2010 02:29 PM
SchoppMatthieu
New Contributor III
Hello,

I'm working on ArcServer 9.3, Flex 4, Esri API for Flex 1.3

I try to get an event (Alert.show) when a user selects one of the group-layer in the Table Of Content. The GroupLayer is in a MapService which contains other GroupLayers that don't requiere any Alert.

E.g. : In the Table Of Content, when the user selects the "NewRoadProject" grouplayer checkbox (the group layer "NewRoadProject" in a mapservice containing other grouplayers) then the AlertShow display : "This data is blablabla".

I'm using the TOC found in the Ressource Centers code gallery.

Among the methods available in the tocClasses (TocItem - TocItemRender - TocLayerInfoItem - TocMapLayerItem) I've got : "Item.label" - "item.isGroupLayer" and some "checkBox - checkBox Selected" functionalities.

I think I need to create an Event Listener in the TOC and a function which will retreive the name of the selected Item. Then if the Item.label name is "NewRoadProject" the alert show is displayed. I tried to play arround with these methods but unsuccessfully.

First Difficulty, I don't manage to get the "Item-methods" in my function. Again, my level is beginner and I would be grateful if someone can help me and get me on the rails.


Matt
Tags (2)
0 Kudos
1 Reply
RobertScheitlin__GISP
MVP Emeritus
Matt,


Here is some code:

//Add this attribute to the toc element
itemRollOver="setLastTreeItem(event)"

//Add these import
import mx.events.ListEvent;
import com.esri.maplib.tocClasses.TocItem;

//Add this var
public var lastTreeItem:ListEvent;

//Add this new function
public function setLastTreeItem(event:ListEvent):void
            {
                lastTreeItem = event;
            }

//Then you can add something like this to your function to get a TocItem
var item:TocItem = TocItem(lastTreeItem.itemRenderer.data);


from the item you can get the label or check for isGroupLayer.
0 Kudos