Some events not shown in month view- fullcalendar - javascript

I'm using fullcalendar v5 to draw events in month view. Events are sorted based on 'eventType'.
day max events is set to '3'.
The problem is some days in a month are not showing any events (or less than the dayMaxEvents, notice April 1 in screenshot), and shows +more.
I tried to figure out why this is happening, and I think it's because these events start on a previous day and this day drew '3' events only (based on sorting), leaving these extending till a certain day hidden.
calendar = new FullCalendar.Calendar(calendarEl, {
plugins: [CustomViewPlugin],
locale: 'en',
contentHeight: 1000,
views: {
year: {
type: 'year',
dayMaxEventRows: 3,
duration: { years: 1 },
titleFormat: { year: 'numeric', month: 'long', day: '2-digit' }
},
week: {
contentHeight: 650,
dayMaxEvents: 10,
dayHeaderFormat: { weekday: 'long' }
},
dayGridMonth: {
contentHeight: 1270,
dayMaxEvents: 3,
dayHeaderFormat: { weekday: 'long' }
},
},
initialView: 'year',
timeZone: 'UTC',
eventClick: function (info) {
let event = info.event;
showEventDetails(event.id);
},
events:
[
// Add your events here
{
title: 'Event 1',
start: '2022-02-26',
end: '2022-04-01',
eventType: "Tier 1"
},
{
title: 'Event 2',
start: '2022-02-26',
end: '2022-04-01',
eventType: "Tier 1"
},
{
title: 'Event 3',
start: '2022-02-26',
end: '2022-04-01',
eventType: "Tier 1"
},
{
title: 'Event 4',
start: '2022-02-26',
end: '2022-04-26',
eventType: 'Tier 2'
},
{
title: 'Event 5',
start: '2022-03-26',
end: '2022-04-26',
eventType: 'Tier 2'
},
{
title: 'Event 6',
start: '2022-03-26',
end: '2022-04-26',
eventType: 'Tier 2'
},
{
title: 'Event 7',
start: '2022-03-26',
end: '2022-04-26',
eventType: 'Tier 2'
},
{
title: 'Event 8',
start: '2022-03-26',
end: '2022-04-26',
eventType: 'Tier 2'
}
],
eventOrder: "eventType",
eventContent: function (info) {
//event content here
},
fixedWeekCount: false,
showNonCurrentDates: true
})
I want a way to always draw events up to dayMaxEvents even the day isn't the start day.

Updating fullcalendar from v5 to v6 solved this issue for me, now all days will have events up to dayMaxEvents.

Related

How to constraint an Event drag n drop in FullCalendar v3 to only All-Day section?

I've looking to disable Drag n Drop of "All Day" events here in below Time grid.
I need to block Drag and Drop of All-Day Events into the Timegrid view below that section. So that All-Day Events should always be droppable in All-Day section and Time based events are draggable and droppable in Time base grid section.
Can this be done with FullCalendar JS?
sample code looks like this:
Codepen
HTML:
<div id='calendar'></div>
CSS:
#calendar {
max-width: 900px;
margin: 40px auto;
}
JS:
$(function() {
$('#calendar').fullCalendar({
defaultView: 'agendaWeek',
editable: true,
eventDurationEditable: false,
eventLimit: true,
nowIndicator: true,
now: '2019-06-09T09:25:00',
events: [
{
title: 'All Day Event',
start: '2019-06-01',
},
{
title: 'Long Event',
start: '2019-06-07',
end: '2019-06-10'
},
{
groupId: 999,
title: 'Repeating Event',
start: '2019-06-09T16:00:00'
},
{
groupId: 999,
title: 'Repeating Event',
start: '2019-06-16T16:00:00'
},
{
title: 'Conference',
start: '2019-06-11',
end: '2019-06-13'
},
{
title: 'Meeting',
start: '2019-06-12T10:30:00',
end: '2019-06-12T12:30:00'
},
{
title: 'Lunch',
start: '2019-06-12T12:00:00'
},
{
title: 'Meeting',
start: '2019-06-12T14:30:00'
},
{
title: 'Happy Hour',
start: '2019-06-12T17:30:00'
},
{
title: 'Dinner',
start: '2019-06-12T20:00:00'
},
{
title: 'Birthday Party',
start: '2019-06-13T07:00:00'
},
{
title: 'Click for Google',
url: 'http://google.com/',
start: '2019-06-28'
}
]
});
});

fullcalendar V4 dayClick not firing

I am trying to convert an old Fullcalendar based web app to V4. I can not get dayClick to fire.
I have this CodePen example: https://codepen.io/anon/pen/YMMEyN?&editable=true&editors=001
The example was initialized via a lik=nk from the FC web site. See below. It brings up a dayGridMonth view by default. It includes the interaction plugin but the dayClick method does not fire, no matter what day cell i click in.
document.addEventListener('DOMContentLoaded', function() {
var calendarEl = document.getElementById('calendar');
var calendar = new FullCalendar.Calendar(calendarEl, {
plugins: [ 'interaction', 'dayGrid', 'timeGrid' ],
defaultView: 'dayGridMonth',
defaultDate: '2019-04-07',
header: {
left: 'prev,next today',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay'
},
dayClick: function(info) {
alert("dayClick ");
},
events: [
{
title: 'All Day Event',
start: '2019-04-01'
},
{
title: 'Long Event',
start: '2019-04-07',
end: '2019-04-10'
},
{
groupId: '999',
title: 'Repeating Event',
start: '2019-04-09T16:00:00'
},
{
groupId: '999',
title: 'Repeating Event',
start: '2019-04-16T16:00:00'
},
{
title: 'Conference',
start: '2019-04-11',
end: '2019-04-13'
},
{
title: 'Meeting',
start: '2019-04-12T10:30:00',
end: '2019-04-12T12:30:00'
},
{
title: 'Lunch',
start: '2019-04-12T12:00:00'
},
{
title: 'Meeting',
start: '2019-04-12T14:30:00'
},
{
title: 'Birthday Party',
start: '2019-04-13T07:00:00'
},
{
title: 'Click for Google',
url: 'http://google.com/',
start: '2019-04-28'
}
]
});
calendar.render();
});
I think you meant dateClick instead of dayClick:
dateClick: function(info) {
alert("dateClick");
},
for reference: dateClick() docs

How do I customise time slots in full calendar?

I am using full-calendar from fullcalendar.io and having some trouble customizing its time slot.
I want to add time slots like breakfast, lunch, dinner etc also user can add his/her own slots. How do I set the fixed height according to the number of slots? Also, I want to set the slot column text for breakfast, lunch etc. not 12 am, 6 am. Here's what I did until now:
var today = moment();
$('#calendar').fullCalendar({
droppable: true,
defaultView: 'Week',
header: false,
defaultDate: today,
navLinks: false, // can click day/week names to navigate views
editable: true,
eventLimit: true, // allow "more" link when too many events
schedulerLicenseKey: 'GPL-My-Project-Is-Open-Source',
/*events: [
{
title : 'event1',
start : today,
imageurl:'assets/images/recipe/salad.jpg'
}
],*/
/*views: {
agendaWeek: {
agendaEventMinHeight: 150,
allDaySlot: false,
slotLabelInterval: { hours: 6},
slotDuration: { hours: 1},
duration: { days: 7}
}
},*/
eventRender: function (event, element) {
element.find(".fc-event-title").remove();
element.find(".fc-event-time").remove();
var new_description = '#';
element.append(new_description);
},
now: today,
/*header: {
left: 'promptResource',
center: '',
right: ''
},*/
footer: {
left: 'promptResource',
center: '',
right: ''
},
customButtons: {
promptResource: {
text: '+ add course',
click: function() {
var title = prompt('Course name');
if (title) {
$('#calendar').fullCalendar(
'addResource',
{ title: title },
true // scroll to the new resource?
);
}
}
}
},
views: {
Week: {
type: 'timeline',
duration: { Days: '7' },
slotLabelInterval: { hours: 24},
slotDuration: { hours: 24},
}
},
resourceLabelText: 'Meal',
resourceRender: function(resource, cellEls) {
cellEls.on('click', function() {
if (confirm('Are you sure you want to delete ' + resource.title + '?')) {
$('#calendar').fullCalendar('removeResource', resource);
}
});
},
resources: [
{ id: 'a', title: 'Breakfast' , eventColor: 'red'},
{ id: 'b', title: 'Lunch', eventColor: 'green' },
{ id: 'c', title: 'Dinner', eventColor: 'orange' },
{ id: 'd', title: 'Other', eventColor: 'grey'},
],
events: [
{ id: '1', resourceId: 'b', start: today, end: today, title: 'event 1' },
{ id: '2', resourceId: 'c', start: '2018-04-07T05:00:00', end: '2018-04-07T22:00:00', title: 'event 2' },
{ id: '3', resourceId: 'd', start: '2018-04-06', end: '2018-04-08', title: 'event 3' },
{ id: '4', resourceId: 'e', start: '2018-04-07T03:00:00', end: '2018-04-07T08:00:00', title: 'event 4' },
{ id: '5', resourceId: 'f', start: '2018-04-07T00:30:00', end: '2018-04-07T02:30:00', title: 'event 5' }
]
});
<link href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.9.0/fullcalendar.min.css" data-print="true" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.9.0/fullcalendar.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar-scheduler/1.9.4/scheduler.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar-scheduler/1.9.4/scheduler.min.css" />
<div id="calendar"></div>
Any help would be really appreciated.
Edit:
Here's what I actually want to implement.
In design, you can see that the time of the day is not important. I want the users to add as many meals a day as they can. I just a want the option to add the meal's title(event). And remove the time slots on the left side.
update:
I've managed to solve this problem to some extent. Here's how it looks now:
But still, there are some problems like how can I change the date format in columnHeader and how can I give fix size to row and columns?

Highlight day cell as per given date

I need to highlight a specific day from the fullcalendar using JavaScript/jQuery. The date should be given by user input. I have provided my code below:
<style type="text/css">
.cellBg {
background: #000;
color: #fff;
}
</style>
$(document).ready(function() {
var today=new Date().toISOString().substring(0, 10);
var highligtDate="2017-12-05";
console.log('today',today);
$('#calendar').fullCalendar({
theme: true,
header: {
left: 'prev,next',
center: 'title',
right: 'month,agendaWeek,agendaDay,today,listMonth'
},
dayRender:function(date,cell){
date = new Date();
date = $.fullCalendar.formatDate(date, 'yyyy-MM-dd');
$('.fc-day[data-date="'+ date +'"]').addClass('cellBg');
},
///////// edit
dayClick: function (date, jsEvent, view) {
//alert('day click');
},
eventClick:
function (event, jsEvent) {
//alert('event clicked');
$('#eventpopup').modal({
backdrop: 'static'
});
},
///////////
defaultDate: today,
navLinks: true, // can click day/week names to navigate views
editable: true,
eventLimit: true, // allow "more" link when too many events
events: [
{
title: 'All Day Event',
start: '2017-05-01'
},
{
title: 'Long Event',
start: '2017-05-07',
end: '2017-05-10'
},
{
id: 999,
title: 'Repeating Event',
start: '2017-05-09T16:00:00'
},
{
id: 999,
title: 'Repeating Event',
start: '2017-05-16T16:00:00'
},
{
title: 'Conference',
start: '2017-05-11',
end: '2017-05-13'
},
{
title: 'Meeting',
start: '2017-05-12T10:30:00',
end: '2017-05-12T12:30:00'
},
{
title: 'Lunch',
start: '2017-05-12T12:00:00'
},
{
title: 'Meeting',
start: '2017-05-12T14:30:00'
},
{
title: 'Happy Hour',
start: '2017-05-12T17:30:00'
},
{
title: 'Dinner',
start: '2017-05-12T20:00:00'
},
{
title: 'Birthday Party',
start: '2017-05-13T07:00:00'
},
{
title: 'Click for Google',
//url: 'http://google.com/',
start: '2017-05-28'
}
]
});
});
Here I have one date var highligtDate="2017-12-05" and I need to highlight this day cell from the calendar.
Compare the date with highligtDate and assign 'cellBg' class to it.There you do not have a condition to assign this class to particular date.
$(document).ready(function() {
var today=new Date().toISOString().substring(0, 10);
var highligtDate="2017-12-05";
console.log('today',today);
$('#calendar').fullCalendar({
theme: true,
header: {
left: 'prev,next',
center: 'title',
right: 'month,agendaWeek,agendaDay,today,listMonth'
},
dayRender:function(date,cell){
//date = new Date();
//date = $.fullCalendar.formatDate(date, 'yyyy-MM-dd');
//Compare the date with highligtDate and assign 'cellBg' class to it.
if(date.format('YYYY-MM-DD') == highligtDate)
{
$('.fc-day[data-date="'+ highligtDate +'"]').addClass('cellBg');
}
},
///////// edit
dayClick: function (date, jsEvent, view) {
//alert('day click');
},
eventClick:
function (event, jsEvent) {
//alert('event clicked');
$('#eventpopup').modal({
backdrop: 'static'
});
},
///////////
defaultDate: today,
navLinks: true, // can click day/week names to navigate views
editable: true,
eventLimit: true, // allow "more" link when too many events
events: [
{
title: 'All Day Event',
start: '2017-05-01'
},
{
title: 'Long Event',
start: '2017-05-07',
end: '2017-05-10'
},
{
id: 999,
title: 'Repeating Event',
start: '2017-05-09T16:00:00'
},
{
id: 999,
title: 'Repeating Event',
start: '2017-05-16T16:00:00'
},
{
title: 'Conference',
start: '2017-05-11',
end: '2017-05-13'
},
{
title: 'Meeting',
start: '2017-05-12T10:30:00',
end: '2017-05-12T12:30:00'
},
{
title: 'Lunch',
start: '2017-05-12T12:00:00'
},
{
title: 'Meeting',
start: '2017-05-12T14:30:00'
},
{
title: 'Happy Hour',
start: '2017-05-12T17:30:00'
},
{
title: 'Dinner',
start: '2017-05-12T20:00:00'
},
{
title: 'Birthday Party',
start: '2017-05-13T07:00:00'
},
{
title: 'Click for Google',
//url: 'http://google.com/',
start: '2017-05-28'
}
]
});
});

Full Calender + Right Click is not working on the cell when events are added

I am using Full Calender JQuery Plugin for displaying my user's daily activity. I have added one drop-down menu when user right click on any cell. But I have an issue with that when we add an event on any cell. When we add an event on any cell then it will create a on the whole row, So I am not able to add open drop-down menu on whole row.
It's displayed on the attached image. On red portion i may not able to open drop-down on right click.
Code
$(document).contextmenu({
delegate: ".hasmenu",
autoFocus: true,
preventContextMenuForPopup: true,
preventSelect: true,
taphold: true,
menu: [{
title: "Block Date",
cmd: "block",
uiIcon: ""
}],
// Handle menu selection to implement a fake-clipboard
select: function (event, ui) {
// Block Date Code
},
// Implement the beforeOpen callback to dynamically change the entries
beforeOpen: function (event, ui) {
// Optionally return false, to prevent opening the menu now
}
});
$('#my-calendar').fullCalendar({
buttonText: {
today: 'Today',
month: 'Month',
week: 'Week',
day: 'Day',
list: 'List'
},
header: {
left: 'month,basicWeek,basicDay',
center: 'prev, title, next',
right: 'month,basicWeek,basicDay'
},
timeFormat: 'H:mm',
navLinks: true, // can click day/week names to navigate views
editable: false,
eventLimit: true, // allow "more" link when too many events
eventClick: function(event, jsEvent, view) {
// Code for display popup for event
},
dayRender: function (day, cell) {
// Code for add hasmenu class for open context menu on right click
},
events: [
{
title: 'All Day Event',
start: '2017-07-01',
color: '#000'
},
{
title: 'Long Event',
start: '2017-07-07',
end: '2017-07-10'
},
{
id: 999,
title: 'Repeating Event',
start: '2017-07-09T16:00:00'
},
{
id: 999,
title: 'Repeating Event',
start: '2017-07-16T16:00:00'
},
{
title: 'Conference',
start: '2017-07-11',
end: '2017-07-13'
},
{
title: 'Meeting',
start: '2017-07-12T10:30:00',
end: '2017-07-12T12:30:00'
},
{
title: 'Lunch',
start: '2017-07-12T12:00:00'
},
{
title: 'Meeting',
start: '2017-07-12T14:30:00'
},
{
title: 'Happy Hour',
start: '2017-07-12T17:30:00'
},
{
title: 'Dinner',
start: '2017-07-12T20:00:00'
},
{
title: 'Birthday Party',
start: '2017-07-13T07:00:00'
},
{
title: 'Click for Google',
url: 'http://google.com/',
start: '2017-07-28'
}
]
});

Categories

Resources