【问题标题】:Kendo Scheduler: Prevent editing for completed eventKendo Scheduler:防止编辑已完成的事件
【发布时间】:2014-02-13 08:02:40
【问题描述】:
如何防止编辑已在 kendo 调度程序中完成的事件。
以下是两种情况:
假设活动从 2014 年 1 月 5 日开始,并且持续(每天)10 天,即到 2014 年 1 月 15 日。所以现在不应该编辑它(现在=当前日期)
事件于 2014 年 2 月 5 日宣布,并将持续(每天)到 2 月 25 日。 8 天后,即 2 月 13 日,编辑了整个活动系列。它应仅在 2 月 13 日至 2 月 25 日期间生效,并且不应完成一次。
任何帮助都将不胜感激。
【问题讨论】:
标签:
javascript
kendo-ui
kendo-scheduler
【解决方案1】:
@(Html.Kendo().Scheduler<ViewModel>()
.Name("scheduler")
.Date(DateTime.Today)
.Events(events => events
.Edit("ShowBookingPopup")
.Save("ShowBookingPopup")
......
)
*ShowBookingPopup - 是自定义的 java 脚本函数,您可以通过它有一个条件来允许或阻止编辑,如下所示。
function ShowBookingPopup(e) {
var today = new Date();
// Your custom condition to allow/block editing of the event
if (e.event.Start < today) {
// If the event date is in the past then disallow update by blocking the default behavior and showing an alert for the same
setTimeout(function () {
alert("Cannot edit the event.");
}, 0);
e.preventDefault();
}
}
您还可以使用 Telerik 事件示例中说明的其他事件,并根据您的调度程序行为进行自定义。
http://demos.telerik.com/kendo-ui/web/scheduler/move-resize.html