Getting graphics index by clicking on infoRenderer

1038
4
12-14-2010 12:54 PM
AlexanderStepanov
New Contributor II
Hi all:

I appreciate if someone could give me a hint on the following problem.

In application, I have a graphics layer which has a DataProvider property set to an array collection.
(so the array collection consists of points with attributes and is a data source for my graphics layer).

To define a style of points and to draw them, I use infoRenderer with states: one of states has a button "delete". The idea is to able a user to delete point from a layer. ( in other words I need to remove an object from the arrayCollection/dataProvider by its index.

I still cannot figure out how ( when a user clicks on "delete" button ) to get an index of the graphic in the array collection?

Kind regards,
Alexander
Tags (2)
0 Kudos
4 Replies
ReneRubalcava
Frequent Contributor
You can add an eventListener to each graphic in the arraycollection,then when it gets clicked, save that item so that when you click on delete you can find it in the ArrayCollection.
So, something like this.
var graphic:Graphic = event.currentTarget as Graphic;
var i:int = arrayCollection.getItemIndex(graphic);
arrayCollection.removeItemAt(i);
0 Kudos
AlexanderStepanov
New Contributor II
Rene, thank you for your prompt reply.

one of the problems here is that arrayCollection is not in scope of infoRenderer.
So from itemRenderer I need to get it's index in the collection.

Kind regards,
Alexander
0 Kudos
DasaPaddock
Esri Regular Contributor
0 Kudos
AlexanderStepanov
New Contributor II
Dasa and Rene, thank you for your help.

It works fine now!

Kind regards,
Alexander
0 Kudos