我有Scheduler加载多个约会。其中一些约会应该是只读的,用户不应该选择它们。但是,他们应该能够选择和编辑一些约会。此逻辑在服务器上确定,并在加载时作为有效负载中的字段传递。
我试图挂钩几个客户端事件,例如Edit,MoveStart和ResizeStart,并取消编辑事件。这确实有效,但我希望用户甚至无法选择该事件。
我没有看到任何客户端事件选择我可以取消。
我确实尝试迭代DataBound上的约会,但不确定如何防止在那时选择。
我建议使用自定义事件模板和编辑按钮,并为调度程序将可编辑和可选属性设置为false。
<script id="event-template" type="text/x-kendo-template">
<div>
<label>Title: #: title #<label>
# if (allowEdit) { #
<button style="margin-left:50px;" onclick="editSchedulerEvent(#:id#)">Edit</button>
# } #
</div>
<div>
Attendees:
# for (var i = 0; i < resources.length; i++) { #
#: resources[i].text #
# } #
</div>
</script>
<div id="scheduler"></div>
<script>
function editSchedulerEvent(id){
var scheduler = $("#scheduler").data("kendoScheduler");
var event = scheduler.dataSource.get(id);
scheduler.editEvent(event);
}
$("#scheduler").kendoScheduler({
date: new Date("2013/6/6"),
eventTemplate: $("#event-template").html(),
editable: false,
selectable: false,
dataSource: [
{
id: 1,
start: new Date("2013/6/6 08:00 AM"),
end: new Date("2013/6/6 09:00 AM"),
title: "Interview",
atendees: [1,2],
allowEdit: true
},
{
id: 2,
start: new Date("2013/6/6 10:00 AM"),
end: new Date("2013/6/6 11:00 AM"),
title: "Interview",
atendees: [3,4],
allowEdit: false
}
],
resources: [
{
field: "atendees",
dataSource: [
{ value: 1, text: "Alex" },
{ value: 2, text: "Bob" },
{ value: 3, text: "John" },
{ value: 4, text: "Jane" }
],
multiple: true
}
]
});
</script>
</body>
</html>