isNew
Checks if the Model
is new or not. The id
field is used to determine if a model instance is new or existing. If the value of the specified field is equal to the default value that is specified through the fields
configuration, the model is considered new.
Returns
Boolean
—Returns true
if the field is editable. Otherwise, returns false
.
Example - check if a model is new
<script>
var Product = kendo.data.Model.define({
id: "productId",
fields: {
productId: {
editable: false
}
}
});
var productOne = new Product();
console.log(productOne.isNew()); // outputs "true"
var productTwo = new Product({ productId: 1 });
console.log(productTwo.isNew()); // outputs "false" because productId is set to 1
</script>