Thanks...I wish I had a good example of when that didn't work for me...  I
had times when the data would be filtered down such that the item previously
selected was still selected, but its index had changed.  If I tried to tell
the grid to select the new index, it ignored my command because the same
item was selected.  I had to toggle no selection/selection to get it to
behave properly.

The selectedIndex behavior really seems like a bug to me...  <
http://flexninja.com/examples/DGFilterTest/DGFilterTest.html>.  If you type
'3' for example, only 3 and 13 will be left, but the grid will claim the
selectedIndex is 3 (because that's 3's previous index.)

On Thu, Jan 15, 2009 at 6:03 PM, Tim Hoff <timh...@aol.com> wrote:

>
> One way is to bind a variable to the selectedIndex of the DataGrid:
>
> [Bindable]
> private var selectedIndex:int = -1;
>
> <mx:DataGrid selectedIndex="{ selectedIndex }"/>
>
> Then when you filter the collection:
>
> myCollection.filterFunction = myFilterFunction;
> myCollection.refresh();
>
> selectedIndex = (myCollection.length > 0 ? 0 : -1);
>
> -TH
>
>
> --- In flexcoders@yahoogroups.com <flexcoders%40yahoogroups.com>,
> "dfalling" <dfall...@...> wrote:
> >
> > Is there a way of getting accurate selectedIndex from an datagrid
> > that's bound to a filtered data provider? I'm running into the same
> > problem from several different angles... I ask a datagrid what its
> > selectedIndex is and it claims it's 10. I tell it to select index 0
> > instead, at which point it dispatches the change event and is still
> > set to 0.
> >
> > I'm simply trying to make sure that when the collection is filtered,
> > the grid selects the first item in the list to allow for easy keyboard
> > navigation.
> >
> > Cheers.
> >
>
>  
>

Reply via email to