How do I maintain selection in a DataGrid when the data changes?
问题 I have a DataGrid and I set the DataProvider to my data. When my data changes the DataGrid loses the selected row and the scroll bar jumps back to the top. How do I maintain the selection and scroll position? 回答1: If you just want to maintain position: in whatever function is changing the data, first capture the selected index var myidx:int = new int(myDG.selectedIndex); and the scroll position var myVertPos:int = new int(myDG.verticalScrollPosition); run the code that changes the data then