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 [email protected], "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.
>