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

Modify one field in a MVVM DataSource

1 Answer 63 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Dr.YSG
Top achievements
Rank 2
Dr.YSG asked on 26 Jun 2013, 08:43 PM
I have a DataSource that I am using as the VM for a Grid.

After the reader grabs the data, I have a change event that I need to run to compare what is local (in an indexed db) with what was fetched.

In the snippet below I set row[i].Newer to false if the data is not newer.
Then I trigger the change on the ObservableObject.

This is all working fine, until I do a "cancel changes" from the Grid Toolbar. which seems to reset things.

How should I be updating the DS?
if (vm.oldTest(layers.at(i).Type, layers.at(i).Date, dbm.LayerInfo)) {
    layers.at(i).Newer = false;
    layers.at(i).trigger("change");
}

1 Answer, 1 is accepted

Sort by
0
Accepted
Petur Subev
Telerik team
answered on 28 Jun 2013, 10:17 AM
Hello,

The dataSource of the Grid keeps copy of the 'original' dataItems (it saves it when the Grid is bound) and when the cancelChangs is invoked - all the items from that pristine collection are used and all other changes applied are lost.

If sync of the dataSource is called - on success the pristine collection is updated with these successfully updated dataItems.

Kind Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Data Source
Asked by
Dr.YSG
Top achievements
Rank 2
Answers by
Petur Subev
Telerik team
Share this question
or