在 Kendo Scheduler for ASP.NET MVC 中将某些约会标记为不可选择
Marking certain appointments as not selectable in Kendo Scheduler for ASP.NET MVC
我让调度程序加载多个约会。其中一些约会应该是只读的,用户不应该 select 它们。不过,他们应该能够 select 和编辑一些约会。其逻辑在服务器上确定并在加载时作为有效负载中的字段传递。
我试图连接到多个客户端事件,例如 Edit、MoveStart 和 ResizeStart 并取消编辑事件。这确实有效,但我希望用户甚至无法 select 事件。
我没有看到任何我可以取消的选择客户端事件。
我确实尝试遍历 DataBound 上的约会,但不确定当时如何防止 selecting。
我建议使用带有编辑按钮的自定义事件模板,并将调度程序的可编辑和可选属性设置为 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>
我让调度程序加载多个约会。其中一些约会应该是只读的,用户不应该 select 它们。不过,他们应该能够 select 和编辑一些约会。其逻辑在服务器上确定并在加载时作为有效负载中的字段传递。
我试图连接到多个客户端事件,例如 Edit、MoveStart 和 ResizeStart 并取消编辑事件。这确实有效,但我希望用户甚至无法 select 事件。
我没有看到任何我可以取消的选择客户端事件。
我确实尝试遍历 DataBound 上的约会,但不确定当时如何防止 selecting。
我建议使用带有编辑按钮的自定义事件模板,并将调度程序的可编辑和可选属性设置为 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>