我已经为内联网格编辑定义了一个自定义错误消息,该消息在某些元素上可完美运行,但对所有元素均无效。 在常规元素(如文本)上显示了自定义错误消息,但是在下拉列表“ CertificateTypeId”上,我得到了默认错误消息:“ CertificateTypeId is required”
定义自定义验证的模式代码:
fields: {
CertificateTypeId: { type: "string", validation: { required: { message: 'Custom message' } } },
LastName: { type: "string", validation: { required: { message: 'Custom message' } } },
}
创建下拉列表的代码,定义列部分中的函数调用:
// Define the column section
var arrColums = [
{ field: "CertificateTypeId", title: "Some title", filterable: false, width: 150, headerAttributes: { style: "white-space: normal" }, editor: createDropDownEditor, template: "#=setDescription(CertificateTypeId,'CertificateTypes')#" },
{ field: "LastName", title: "Some title", filterable: false, width: 170, headerAttributes: { style: "white-space: normal" } }
]
function createDropDownEditor(container, options) {
var collectionName = "";
var dataTextField = "Description";
var dataValueField = "Id";
$('<input required name="' + options.field + '"/>')
.appendTo(container)
.kendoDropDownList({
optionLabel: "Choose",
dataTextField: dataTextField,
dataValueField: dataValueField,
dataSource: {
type: "odata",
data: collection
},
filter: "contains",
});
$("<span class='k-invalid-msg' data-required-msg='שדה חובה' data-for='" + options.field + "'></span>").appendTo(container);
}