idFieldString
The name of the Model
ID field. This field is available only if the id
is defined in the Model configuration.
Example
<script>
var Product = kendo.data.Model.define({
id: "productId",
fields: {
productId: { type: "number" },
name: { type: "string" }
}
});
var product = new Product({ productId: 1, name: "Sample Product" });
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(product.idField); // outputs "productId"
</script>
<script>
var Person = kendo.data.Model.define({
id: "personId",
fields: {
"name": {
type: "string"
},
"age": {
type: "number"
}
}
});
var person = new Person({
personId: 1,
name: "John Doe",
age: 42
});
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(person.id); // outputs 1
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(person.idField); // outputs "personId"
</script>
In this article