目前,我希望在保存更改之前验证新创建的行, schema不能在所创建的行上强制执行规则。 如果用户尝试使用错误消息进行保存,我需要让用户知道需要哪些字段。
此示例已经进行了自定义验证,您可以在架构中看到它,在提交服务器之前它没有强制验证的问题。
var gResult = new kendo.data.DataSource({
read:,
update:,
create:,
schema: {
model: {
id: "Id",
fields: {
Id: { type: 'number' },
Color: { type: 'string', defaultValue: "#000" },
Name: {type: 'string', validation: { required: true } },
Address1: { validation: { required: true } },
City: { validation: { required: true } },
Country: { validation: { required: true }, defaultValue: "Deutchland" },
PostalCode: { type: 'number', validation: { required: true } },
Emails: {
type: 'string',
validation: {
required: { message: "Email ID Required." },
validateEmailFormat: function (input) {
if (input.attr("data-bind") == "value:Email") {
input.attr("data-validateEmailFormat-msg", "Email format invalid.");
return checkEmail(input.val());
}
return true;
}
}
}
}
}
});
$("#gridResult").kendoGrid({
columns: GridColumns.Columns,
dataSource: gResult,
navigatable: true,
sortable: true,
height: 1000,
filterable: true,
pageable: GridProp.Pageable,
editable: true, toolbar: ["create", "save"] });