Track changes in Observable collection

5 posts, 1 answers
  1. Norbert John
    Norbert John avatar
    16 posts
    Member since:
    Dec 2009

    Posted 12 May 2010 Link to this post

    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

  2. Answer
    Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 13 May 2010 Link to this post

    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.
  3. M
    M avatar
    23 posts
    Member since:
    Jun 2010

    Posted 08 Jun 2010 Link to this post

    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.
  4. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 08 Jun 2010 Link to this post

    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.
  5. M
    M avatar
    23 posts
    Member since:
    Jun 2010

    Posted 11 Jun 2010 Link to this post

    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.
Back to Top