Model class sets dirty = true even if set event is cancelled

Brian Roth

When calling set() on a kendo Model object, the 'dirty' field appears to be set to true even if the set is cancelled from the "set" event. See http://dojo.telerik.com/UMOVU for an example of this behavior.

After a little research, I found that the kendo.data.Model.set() function is setting dirty = true before calling ObservableObject.set():

set: function(field, value, initiator) {

varthat = this;

if(that.editable(field)) {

value = that._parse(field, value);

if(!equal(value, that.get(field))) {

that.dirty = true;

ObservableObject.fn.set.call(that, field, value, initiator);

}

}

},

The problem could be fixed by doing something like this instead:

set: function(field, value, initiator) {

varthat = this;

if(that.editable(field)) {

value = that._parse(field, value);

if(!equal(value, that.get(field))) {

// ObservableObject.set() should return a value indicating whether or not the default was prevented.

if(!ObservableObject.fn.set.call(that, field, value, initiator))

that.dirty = true; // Only set dirty = true if the value was actually modified.

}

}

},

Answer

Nikolay Rusev

Thank you for the feedback we will update the reference implementation to revert dirty state back to its original value if set event is prevented. The change should be available with next internal build.

Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks or appropriate markings.