서버에서 일부 오류가 반환되면 유효성 검사 오류를 표시하는 응답 이벤트 및 호출 기능에 연결할 수 있습니다.
validationMessageTemplateForReplace = kendo.template(
'<div class="k-widget k-tooltip k-tooltip-validation k-invalid-msg field-validation-error" style="margin: 0.5em; display: block; " data-for="#=field#" data-valmsg-for="#=field#" id="#=field#_validationMessage">' +
'<span class="k-icon k-warning"> </span>#=message#<div class="k-callout k-callout-n"></div></div>');
function onResponseEnd(response) {
if (response.errors) onError(response.errors, $('#myForm'));
}
function onError(errors, element) {
for (var error in errors) {
addValidationMessage(element, error, errors[error].errors);
}
}
function addValidationMessage(container, name, errors) {
//add the validation message to the form
var found = container.find("[data-for=" + name + "],[data-val-msg-for=" + name + "],[data-valmsg-for=" + name + "]");
if (found.length > 0) {
found.replaceWith(bs.validationMessageTemplateForReplace({ field: name, message: errors[0] }));
return true;
}
return false;
}
어쩌면
this 예제 프로젝트는 또한 당신을 위해 도움이 될 것입니다 : 여기
그것을 할 수있는 자바 스크립트 섹션입니다. 그리드 팝업 편집과 연관되어 있지만 달성하려는 메커니즘을 보여줍니다.