Yes, do not use Array (or XMLList) as a dataProvider if you need to update
it at run time.  Neither of those dispatches the necessary events to update
the visual controls.  Use a collection.

 

You cannot use an associative array (Object) as a dataProvider.

 

Tracy Spratt,

Lariat Services, development services available

  _____  

From: [email protected] [mailto:[email protected]] On
Behalf Of turbo_vb
Sent: Thursday, August 27, 2009 11:00 PM
To: [email protected]
Subject: [flexcoders] Re: Is there a way to get the original array index of
a selection in a datagrid?

 

  

Hi Paul,

If you use an ArrayCollections as the dataProvider for the DataGrid instead,
you can remove an item like so:

myArrayCollection.removeItemAt( myDataGrid.selectedIndex );

The DataGrid's selectedIndex is the same as the index of the item in the
ArrayCollection.

-TH

--- In [email protected], "tendancer2000" <tendan...@...> wrote:
>
> I have a datagrid with an Array dataprovider. A user double clicks on a
row which takes them to a new state where they can do things with that data
item including an action that should remove it from the original array.
> 
> I was planning on using the selectedIndex property to index into the array
but I see that is an index into the datagrid, not the original array.
> 
> Since I have the selected Object I can loop around my original array until
I find it, and then remove it, but that's not real efficient. The better
solution is probably to redesign my array, make it associative, but I am
curious to know if there is a way to do it with what there already is.
> 
> Thanks, and thanks to Alex for answering my previous question.
> 
> Paul
>



Reply via email to