Hi there,
I've a Scheduler and a Grid, i want to update the schedule when someone create or update the items in the grid.
I've subscribed the sync event with: .Events(events => events.Sync("sync"))
then I update the scheduler:
function sync(args) {
$("#scheduler").data("kendoScheduler").dataSource.read();
$("#scheduler").data("kendoScheduler").refresh();
}
it works, but if there is a server validation error the editor popup quits and the user can't see the validation error.
How can I detect a successfully update?
Server validation is implemented as in the example provided:
<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>
<script type="text/javascript">
var validationMessageTmpl = kendo.template($("#message").html());
function error(args) {
if (args.errors) {
var grid = $("#grid").data("kendoGrid");
grid.one("dataBinding", function (e) {
e.preventDefault(); // cancel grid rebind if error occurs
for (var error in args.errors) {
alert(args.errors[error].errors);
showMessage(grid.editable.element, error, args.errors[error].errors);
}
});
}
}
function showMessage(container, name, errors) {
//add the validation message to the form
container.find("[data-valmsg-for=" + name + "],[data-val-msg-for=" + name + "]")
.replaceWith(validationMessageTmpl({ field: name, message: errors[0] }))
}
</script>
I've a Scheduler and a Grid, i want to update the schedule when someone create or update the items in the grid.
I've subscribed the sync event with: .Events(events => events.Sync("sync"))
then I update the scheduler:
function sync(args) {
$("#scheduler").data("kendoScheduler").dataSource.read();
$("#scheduler").data("kendoScheduler").refresh();
}
it works, but if there is a server validation error the editor popup quits and the user can't see the validation error.
How can I detect a successfully update?
Server validation is implemented as in the example provided:
<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>
<script type="text/javascript">
var validationMessageTmpl = kendo.template($("#message").html());
function error(args) {
if (args.errors) {
var grid = $("#grid").data("kendoGrid");
grid.one("dataBinding", function (e) {
e.preventDefault(); // cancel grid rebind if error occurs
for (var error in args.errors) {
alert(args.errors[error].errors);
showMessage(grid.editable.element, error, args.errors[error].errors);
}
});
}
}
function showMessage(container, name, errors) {
//add the validation message to the form
container.find("[data-valmsg-for=" + name + "],[data-val-msg-for=" + name + "]")
.replaceWith(validationMessageTmpl({ field: name, message: errors[0] }))
}
</script>