问题描述
我有一个计划程序,供创作者和消费者使用.创建者将定义一个特定的时间范围(创建事件),消费者可以在其中进行交互.在当天的其他时间范围内,消费者无法互动,因此将被禁用.我确实设法创建了事件,没有任何问题,但是显示用于交互的可用插槽导致了我的麻烦.
I have a scheduler which will be used by creators and consumers. Creators will define a specific time range (create an event) in where the consumers can interact. In the other time ranges of that day, consumers can not interact and will be disabled. I did managed to create the events without any problem, but showing the available slots for interaction is causing me problems.
Example:
假设创建者将允许的时间段定义为4:00 pm到8:00 pm(我可以成功将其保存在数据库中并进行相应显示). 因此,在消费者视图中,应从12:00 am至4:00 pm和8:00 pm至12:00 am禁用调度程序,并从4:00 pm至8:00启用调度程序下午.这意味着消费者可以在4:00 pm到8:00 pm之间创建多个事件.
Example:
Suppose, the creator defines the allowed time slot as 4:00 pm to 8:00 pm (which I successfully can save in database and display accordingly). So, in the consumers view, the scheduler should be disabled from 12:00 am to 4:00 pm and from 8:00 pm to 12:00 am and enabled from 4:00 pm to 8:00 pm. That means the consumers can create multiple event in between 4:00 pm to 8:00 pm.
我需要可以用作数据源的适当的调度程序选项.
推荐答案
您可以使用保存事件以防止创建事件,而仅显示允许的范围:
You can use the save event to prevent creating the events and simply only show the range that is allowed:
var startLimit = new Date();
startLimit.setHours(4);
startLimit.setMinutes(0);
startLimit.setSeconds(0);
var endLimit = new Date();
endLimit.setHours(8);
endLimit.setMinutes(0);
endLimit.setSeconds(0);
$("#scheduler").kendoScheduler({
date: new Date(),
views: [{
type: "day",
startTime: startLimit,
endTime: endLimit
}],
dataSource: [],
save: function (e) {
if (e.event.start < startLimit || e.event.end > endLimit) {
console.log("disallow"); // show validation error or w/e
e.preventDefault();
}
}
});
这篇关于Kendo UI Scheduler禁用一天中的多个时间跨度/范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!