I have an ArrayCollection that is the dataProvider for a DataGrid.  Every 30 
seconds the objects in the ArrayCollection get replaced with new objects based 
on data received from the server.  At this point, whatever selection that the 
DataGrid had now disappears, even if an object with the same UID is in the 
ArrayCollection.

What's the best way to have the DataGrid retain its selection?  Obviously, an 
object that has the same UID is not enough.  This makes me think that I have 
two options:

1) When updating objects in the ArrayCollection, recycle objects that have the 
same UID.  This would involve copying over every property for that object.

2) When the DataGrid sees that its dataProvider has changed, first make a note 
of the selected item's UID, and then if the selected item has gone away, try to 
find an object with that UID in the dataProvider.

I know I can do option 1, though it would also entail writing code to cull 
objects that should no longer be in the ArrayCollection and add new ones.  I'm 
not sure how best to do option 2.

This seems like a simple task.  My question is, am I missing some better, 
simpler way to accomplish what I'm trying to do?

Thanks.

Ben

Reply via email to