简体   繁体   English

限制全日历事件的创建

[英]Limit creation of events in fullcalendar

I've checked you can constrain some events to be dragged in a period, or to avoid to move to other periods, but I'm looking a feature to block creation of events just in the business hours defined. 我已经检查过您是否可以限制某些事件在某个时期内被拖动,或者避免转移到其他时期,但是我正在寻找一种功能来阻止仅在定义的工作时间内创建事件。

Is it possible to use the "selectable: true" (to be able to create events with clicking in some time and drag to the end, as Google Calendar), but limit to some time spaces ? 是否可以使用“ selectable:true”(以便能够通过单击某些时间来创建事件并将其拖到末尾(如Google日历)),但限制为某些时间空间?

If you have a defined set of time when events will always be restricted to (without variations over time) then you can use a combination of the businessHours and selectConstraint settings to enforce this: 如果您有一组定义的时间,这些事件将始终被限制为(不随时间变化),那么可以结合使用businessHoursselectConstraint设置来强制执行此操作:

businessHours: {
  // days of week. an array of zero-based day of week integers (0=Sunday)
  daysOfWeek: [1, 2, 3, 4], // Monday - Thursday
  startTime: '10:00', // a start time (10am in this example)
  endTime: '18:00', // an end time (6pm in this example)
},
selectConstraint: "businessHours"

In the above example, "businessHours" will grey-out all the areas of the calendar outside the times defined (in this case Monday to Thursday from 10am to 6pm each day). 在上面的示例中,“ businessHours”将在所定义的时间之外(在本例中为周一至周四,每天上午10点至下午6点)将日历的所有区域设为灰色。 Setting "selectConstraint" to "businessHours" means that users cannot select to create new events which fall outside the same time range. 将“ selectConstraint”设置为“ businessHours”意味着用户无法选择创建超出相同时间范围的新事件。

Demo: https://codepen.io/ADyson82/pen/aboqPoo 演示: https : //codepen.io/ADyson82/pen/aboqPoo

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM