This is a migrated thread and some comments may be shown as answers.

Track changes in Observable collection

4 Answers 249 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Norbert John
Top achievements
Rank 1
Norbert John asked on 12 May 2010, 01:22 PM
Hi,

I have a grid bound to an observable collection of xmlnode. When I make changes in grid, that is getting reflected in the bound observable collection. Is there any provision to find only the changed values from the observable collection? 

Please help

Thanks and Regards,
Norbert John

4 Answers, 1 is accepted

Sort by
0
Accepted
Yavor Georgiev
Telerik team
answered on 13 May 2010, 12:39 PM
Hello Norbert John,

The RadGridView control possesses the RowEditEnded event. You can handle it and access the EditedItem property of the GridViewRowEditEndedEventArgs object. Thus you can aggregate all the edited items in a separate collection and iterate over them afterwards and do as you please.

All the best,
Yavor Georgiev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
M
Top achievements
Rank 1
answered on 08 Jun 2010, 04:00 PM
Hi Yavor,

I am doing as you suggested to build a collection of edited items. The problem is if user edits but revert back to the same old value of the cell then its still fired and get aggregated in the list. Is there a neat way of finding the editeditem is *not edited* (not updated with new values) as such.

Thanks.
0
Yavor Georgiev
Telerik team
answered on 08 Jun 2010, 05:03 PM
Hello M,

 You should add an additional check to see if the new value after edit are the same as the old values before edit. You can find the edited object in the NewData property of GridViewRowEditEndedEventArgs object and the old values for the properties of your business object are stored in a Dictionary in the OldValues property. Simply compare all the values in the Dictionary with the properties of your business object to see if any change has been made and then add it to your collection of edited objects.

Kind regards,
Yavor Georgiev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
M
Top achievements
Rank 1
answered on 11 Jun 2010, 04:56 PM
Hi Yavor,

Thanks for the suggestion, it was workable but I end up extending my entity class to have "IsDirty" flag, which I set to true in over ridden method of OnPropertyChanged function in extended class. There is small trick I had to make it workable so that its not set when entity is hydrated that I have to set "IsDirty" to flase when its finished hydration by creating OnDeserialized behavior in extended class.
Tags
General Discussions
Asked by
Norbert John
Top achievements
Rank 1
Answers by
Yavor Georgiev
Telerik team
M
Top achievements
Rank 1
Share this question
or