Hi,
1) I am looking for how to show one or more server side errors beside the fields .As of now able to popup database sever error but not sure how to show it beside the column fields.Please find the demo attached below(By default showing the sever error while updating the code Field).
2) For some reason the Validation messages are showing below the fields and not beside the fields in the form as show in the image.
Here is how I have set it up
Thanks,
Chatrapathi chennam
1) I am looking for how to show one or more server side errors beside the fields .As of now able to popup database sever error but not sure how to show it beside the column fields.Please find the demo attached below(By default showing the sever error while updating the code Field).
2) For some reason the Validation messages are showing below the fields and not beside the fields in the form as show in the image.
Here is how I have set it up
01.
uwdataSource = new kendo.data.DataSource({
02.
transport: {
03.
read: {
04.
url: crudServiceBaseUrl + "/GetUnderwriterData"
05.
},
06.
create: {
07.
url: crudServiceBaseUrl + "/POSTaddUnderwriterData",
08.
type: "POST",
09.
contentType: "application/json"
10.
},
11.
update: {
12.
url: crudServiceBaseUrl + "/POSTUnderwriterData",
13.
type: "POST",
14.
contentType: "application/json"
15.
},
16.
parameterMap: function (options, operation) {
17.
if (operation !== "read" && options.models) {
18.
return kendo.stringify(options.models[0]);
19.
}
20.
},
21.
error: function (args)
22.
{
23.
if (args.errors) {
24.
alert('there was an error');
25.
var grid = $("#underwriterGrid").data("kendoGrid");
26.
grid.one("dataBinding", function (e) {
27.
e.preventDefault();//cancel grid rebind if error occurs
28.
29.
for (var error in args.errors) {
30.
showMessage(grid.editable.element, error, args.errors[error].errors);
31.
}
32.
});
33.
}
34.
35.
}
36.
},
37.
schema: {
38.
//Define the field which contains the error
39.
errors: function (response) {
40.
return response.error;
41.
},
42.
43.
},//End of Schema
});
uwdataSource.bind("error", dataSource_error);
01.
function showMessage(container, Code, errors) {
02.
var validationMessageTmpl = kendo.template($("#message").html());
03.
//add the validation message to the form
04.
container.find("[data-valmsg-for=" + Code + "],[data-val-msg-for=" + Code + "]").replaceWith($(validationMessageTmpl({ field: Code, message: errors[0] })))
05.
// .replaceWith(validationMessageTmpl({ field: name, message: errors[0] }))
06.
}
07.
08.
function dataSource_error(e) {
09.
alert(e.xhr.responseText); // displays "error"
10.
}
//Index.cshtml
<script type=
"text/kendo-template"
id=
"message"
>
<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>
</script>
Thanks,
Chatrapathi chennam