From b4081bc8124fe8dc1ab5a043cbc91e3c43d2bae0 Mon Sep 17 00:00:00 2001 From: Rosen Konstantinov Date: Tue, 16 Feb 2016 10:11:09 +0200 Subject: [PATCH] Parse offline pristine data. Fixes #1442 --- src/kendo.data.js | 2 +- tests/data/datasource/offline.js | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/kendo.data.js b/src/kendo.data.js index b38f9c7ab23..432f5ec7ade 100644 --- a/src/kendo.data.js +++ b/src/kendo.data.js @@ -3270,7 +3270,7 @@ var __meta__ = { // jshint ignore:line this.offlineData(state.concat(destroyed)); if (updatePristine) { - this._pristineData = state; + this._pristineData = this._readData(state); } } }, diff --git a/tests/data/datasource/offline.js b/tests/data/datasource/offline.js index 7de7c4cdeb5..bcc0672c8b1 100644 --- a/tests/data/datasource/offline.js +++ b/tests/data/datasource/offline.js @@ -584,6 +584,33 @@ equal(dataSource.total(), 1); }); + test("synced inserted item remains after cancelChanges - with projection", function() { + var dataSource = new kendo.data.DataSource({ + offlineStorage: "key", + data: [{ Foo: "baz", id: 1 } ], + schema: { + model: { + id: "id", + fields: { + foo: { from: "Foo" } + } + } + } + }); + + dataSource.read(); + + dataSource.online(false); + + dataSource.add( { foo : "foo" }); + dataSource.sync(); + + dataSource.cancelChanges(); + + equal(dataSource.total(), 2); + equal(dataSource.at(1).foo, "foo"); + }); + test("synced inserted item remains after cancelChanges", function() { var dataSource = new kendo.data.DataSource({ offlineStorage: "key",