I'm entering events into FullCalendar, but I'm having a problem with each event spanning too many hours (or boxes). I need each event to use a checkbox to make it look neater.
This is the JSON of my event id:
'{{ $hora->id }}', title: 'Paciente: {{ $hora->paciente_nombre." ".$hora->paciente_apellido }}
Profesional : {{ $hora->profesional_nombre." ".$hora->profesional_apellido }} ', start: moment('{{ $hora->fecha_hora }}').format('YYYY-MM-DD hh:mm'), backgroundColor: '{{ $hora->color }}',
The issue is that FullCalendar has a
defaultTimedEventDuration
and this is 2 hours:And since you are not specifying the parameter
end
in the event, then the value of 2 hours is assumed as the total duration of the event:So you have two options:
Calculate the parameter
end
by adding 30 minutes to the value of the parameterstart
so that it occupies only one cell using some function.Change the
defaultTimedEventDuration
:What the flag does
forceEventDuration
is force the calculation of theend
.Well, that's what comes to mind for now.
Note
Consider that the solutions that I am proposing go against all the original behavior of FullCalendar which is correct, that is, it is correct that the events have a duration if you have not specified
allDay: true
it and it is also correct that the events overlap when they occur at the same timeAs a complement to @Cesar's answer, if you want to make it look less busy, but still set the actual duration of the events (i.e. without setting the events to 30 min in the 1 hr 30 min case) , you can modify the appearance by taking advantage of the className option . This has the advantage that you move the visual issue out of your application logic. And it allows events to occupy a space proportional to their duration.
Explanation:
.color
where you define the border color and set the background to transparent..color .fc-content
where you put the background color of the area with text and the color of the text itself.className
.Example: