Note, the item instance you pass to selectedItem must be a reference to
an item in the dataProvider.

 

selectedItem will not compare property values of different instances.

 

If you need to set the selectedIndex based on the value of a property,
you must loop over the dataProvider items and do the comparison
yourself.

 

Tracy

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Daniel Gold
Sent: Thursday, June 26, 2008 9:58 AM
To: [email protected]
Subject: Re: [flexcoders] Re: selecting a pre-determined row in a
datagrid

 

list's have a selectedItem property that does the comparison for you to
find the index and select it, so according to your description you could
set grid.selectedItem = selectedItem(the var you're keeping)

On Thu, Jun 26, 2008 at 7:04 AM, bray_6 <[EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> > wrote:

You can use arraycollection getItemIndex() to get the object's index
then use it for the datagrid's selectedIndex.

HTH,
Bray



--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "fb6668" <[EMAIL PROTECTED]> wrote:
>
> Hi.
> 
> I have a datagrid component which has a dataProvider of an
> arraycollection of objects.
> 
> I also have a variable "selectedItem", which holds an object that has
> been selected elsewhere in the application.
> 
> What I need is, when I create my datagrid, to set the background
> colour of the row corresponding to this selectedItem object.
> 
> So I guess I need to loop through the dg's rows, comparing the
> dataItem of the row to selectedItem. However, I don't know how to loop
> the rows in a DataGrid?? 
> It's so easy in C#.NET, and not here, so I think I may be approaching
> this from the wrong angle.
> 
> Any ideas?
> 
> Thanks!
>

 

 

Reply via email to