How do I keep selection after refresh in datagrid flex?
My datagrid is filled with data from an Oracle database. The datagrid ref开发者_如何学Pythonreshes after 1 min. After that, I lose the selected item. I want to avoid that. Consider that it's quite possible that there is new data after refresh, so the selected index may no longer appear in the datagrid after a refresh.
You didn't say how the DataGrid was being refreshed; whether this is something automatic or something you've built. But, in essence, do this:
// before the refresh
storedSelectedItem = dataGridInstance.selectedItem;
// perform code to do the refresh
// after the refresh
dataGridInstance.selectedItem = storedSelectedItem
精彩评论