I'm polling a RemoteObject every 5 seconds using setInterval and the returned result (Array) is being fed into a DataGrid as the DataProvider. However everytime this happens the selected row deselects when the DataGrid is refreshed. So I want to re-select the item when the DataGrid has been updated.
So far I've tried capturing the selected row before the RemoteObject is called using:
private function refreshDataGrid(e:ResultEvent):void
{
var selectedRow:Object = myDataGrid.selectedItem;
myDataGrid.dataProvider = e.result as Array;
myDataGrid.selectedItem = selectedRow;
}
However this doesn't work. If I select the row and then do a "trace(myDataGrid.selectedItem)", the result in the Console is blank.
In another attempt I tried:
private function refreshDataGrid(e:ResultEvent):void
{
var selectedItem:* = myDataGrid.selectedItem.itemId;
myDataGrid.dataProvider = e.result as Array;
myDataGrid.selectedItem.itemId = selectedItem;
}
This doesn't work either.
Can anyone help me make this work? Any help would be greatly appreciated. Thanks in advance.