Allow an event to go through a blocked day

Hi, does anyone know if it is possible to add an event that can not start on a blocked day but can go straight through it. For Example: Have all Sundays blocked but allow an event from a Saturday through to a Monday. This is to be used for a vehicle rental system.

Kind Regards

1 Like

Hello,
you can define a handler for onLimitViolation event, it triggers each time scheduler each time scheduler blocks event creation/edition.
docs.dhtmlx.com/scheduler/api__s … event.html

In the handler you can check whether the event’s start/end dates are out of the blocked time, and if so - allow event placement. scheduler.checkLimitViolation takes an event object as an argument, so you’ll need to create a temporary object with start/end_date properties and probably section id, and test it with .checkLimitViolation method

[code]scheduler.attachEvent(“onLimitViolation”, function (id, event){
if(event.probe) return false;

var allowedStart = scheduler.checkLimitViolation({
	start_date:event.start_date,
	end_date: scheduler.date.add(event.start_date, scheduler.config.time_step, "minute"),
	probe:true//checkLimitViolation invokes onLimitViolation event. Add a property to detect when it's happens by our call
});

var allowedEnd = scheduler.checkLimitViolation({
	start_date:scheduler.date.add(event.end_date, -scheduler.config.time_step, "minute"),
	end_date: event.end_date,
	probe:true
});

if(allowedStart && allowedEnd){
	return true;
}else{
	return false;
}

});[/code]
docs.dhtmlx.com/scheduler/api__s … ation.html
docs.dhtmlx.com/scheduler/api__s … event.html

1 Like

Hi, thats fantastic, thanks for your help. One final point though is that when dragging a normal event it shows the lightbox as I want it to but when dragging over a blocked date it does not show the lightbox, can you help with this also?

Thank You

Hi,
by default the lightbox doesn’t show when dragging an event. What configuration do you use ?

Hi, sorry, I was a little unclear, when creating an event by dragging it over a blocked day it does not show the lightbox. When dragging within a normal time period it does show the lightbox. it also won’t open the lightbox on doubleclick when it lays over the top of a blocked day. I’m using the following lines of configuration:

scheduler.config.details_on_create=true;
scheduler.config.details_on_dblclick=true;

I was actually slightly wrong in my previous post. Please let me describe:

On creation of an event that moves through a blocked timespan, it will not auto show the lightbox.

On double click of an event running through a blocked timespan It does show the lightbox.

I can’t, however, extend, drag or move an event that is running through a blocked timespan.

Thanks in advance for your time and help.

Hi,
could you attach a complete demo to inspect the issue?

Hi Sorry, just realised you had replied, please find my code below:

[code]
[/code]