Edit this page

set event

Fired when the set method is invoked.

The set event is raised before the field value is updated. Calling the get method from the event handler will return the old value. Calling e.preventDefault will prevent the update of the field and the change event will not be raised.

Event Data

e.field String

The name of the field which is retrieved.

e.value Number |String |Data |Object

The new value.

e.preventDefault Function

A function which may prevent the update of the value. Can be used to perform validation.

Example - subscribe to the set event

<script>
var observable = new kendo.data.ObservableObject({ name: "John Doe" });
observable.bind("set", function(e) {
    console.log(e.field); // will output the field name when the event is raised
});
observable.set("name", "Jane Doe"); // raises the "set" event and the handler outputs "name"
</script>

Example - perform validation by preventing the set event

<script>
var observable = new kendo.data.ObservableObject({ name: "John Doe" });
observable.bind("set", function(e) {
    if (e.field == "name") {
        if (!e.value) {
            // avoid emtpy value for the "name" field
            e.preventDefault();
        }
    }
});
observable.set("name", "Jane Doe");
</script>
Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article

close
Dummy