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

How to identify whether data source is modified or not..?

5 Answers 1467 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
aremuga
Top achievements
Rank 1
aremuga asked on 30 Nov 2012, 10:00 AM
Thanks in advance..

5 Answers, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 03 Dec 2012, 04:02 PM
Hi Aremuga,

The dataSource does not expose a method for checking if there are unsaved changes or not.
Could you please provide more details about your scenario? In case you use a Grid control with batch editing you may check whether there are records with dirty property set to true.

Regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Rayne
Top achievements
Rank 1
answered on 09 Jan 2013, 06:02 PM
Could you post a sample of how this would work?

In my application, I want to use external buttons to do the save/cancel changes and I'd like to alert the user and remind them to save their changes before navigating away from the page. I'd also like to enable/disable the save/cancel buttons depending on whether there are changes that need to be saved or not.
0
Alexander Valchev
Telerik team
answered on 11 Jan 2013, 12:16 PM
Hi Rayne,

Basically you have to loop through the dataSource.data() array and check whether there is an item with a dirty property set to true or whether the item is new.

var data = dataSource.data();
 
for (idx = 0, idx < data.length; idx++) {
    if (data[idx].isNew() || data[idx].dirty) {
        return true;
    }
}

As a general information we plan to provide a build-in hasChanges method in the next release.

All the best,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Achilles
Top achievements
Rank 1
answered on 20 Nov 2013, 05:31 AM
Hi Alexender,

Is the hasChanges method available already ?
If so can you provide a sample just like you had for the dataSource.data() looping mechanism

Thanks in Advance

Achilles
0
Alexander Valchev
Telerik team
answered on 20 Nov 2013, 08:17 AM
Hi Achilles,

Yes, the hasChanges method is now available and is documented here:

Regards,
Alexander Valchev
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
aremuga
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Rayne
Top achievements
Rank 1
Achilles
Top achievements
Rank 1
Share this question
or