Using templates is a valid solution. However, if you want your model to always have a composite or calculation field, you can define the analysis function in the definition of the scheme.
schema: { data: "d", model: { id: "PersonId", fields: { PersonId: { type: "number", editable: false // this field is not editable }, FirstName: { type: "string", validation: { // validation rules required: true // the field is required } }, LastName: { type: "string", validation: { // validation rules required: true // the field is required } }, Name: { type: "string" // add any other requirements for your model here } } }, parse: function (response) { var values = response.d, n = values.length, i = 0, value; for (; i < n; i++) { value = values[i]; value.Name = kendo.format("{0} {1}", value.FirstName, value.LastName); } return response; } }
The parsing function pre-processes the server response before using it, so you can modify existing fields or add new ones. Then you can refer to the field (s) directly in any controls that use the model.
Kevin babcock
source share