How to show all events without range limitation in fullcalendar? - javascript

I want to show all events without any limitation in fullcalendar v5.
Here's my code.
document.addEventListener('DOMContentLoaded', function() {
var calendarEventsEl = document.getElementById('calendar-events');
calendarEvents = new FullCalendar.Calendar(calendarEventsEl, {
initialView: 'listMonth',
navLinks: false, // can click day/week names to navigate views
dayMaxEvents: true,
eventTimeFormat: {
hour: 'numeric',
minute: '2-digit',
meridiem: false
},
eventSources: [{
method: 'POST',
url: '/calendar/get_all',
failure: function() {
document.getElementById('script-warning').style.display = 'block'
}
}]
});
calendarEvents.render();
})
At this moment, I can show all events for the month.
If I check the response for eventSources api, the response has all events.
But what I want to do is to show all events without any limitation like week, month, etc.
I tried to change the initialView option to list and tried to set validRange and visibleRange to null.
Any ideas?

When there are too many events, a link that looks like “+2 more” is displayed. The exact action that happens when the user clicks the link is determined by eventLimitClick.
A value of false (the default) will display all events as-is.
A value of true will limit the number of events to the height of the day cell. View a live demo.
An integer value will limit the events to a specific number of rows.
For the all-day section in the TimeGrid views, a value of true will limit the number of events to 5. To fine-tune this, use View-Specific Options like this:
var calendar = new Calendar(calendarEl, {
eventLimit: true, // for all non-TimeGrid views
views: {
timeGrid: {
eventLimit: 6 // adjust to 6 only for timeGridWeek/timeGridDay
}
}
});

Related

setOption startParam works weird in fullcalendar v5

I was trying to set startParam option dynamically.
But it seems working weird by updating the key rather update value.
calendarEvents.setOption('startParam', moment().format());
calendarEvents.refetchEvents();
If I run the methods and check the form data, then the startParam will be look like the following.
2021-02-15T19:09:13-07:00: 2021-01-01T00:00:00-07:00
end: 2030-01-01T00:00:00-07:00
I guess the setOption method updates the key not value for the start params.
Why does this happen and how to fix this?
UPDATE: My calendar code
calendarEvents = new FullCalendar.Calendar(calendarEventsEl, {
headerToolbar: false,
contentHeight: 300,
initialView: 'listAll',
views: {
listAll: {
type: 'listYear',
duration: { years: 9 },
},
},
navLinks: false,
eventDidMount: function (arg) {
...
},
eventTimeFormat: {
hour: 'numeric',
minute: '2-digit',
meridiem: 'short'
},
eventSources: [{
method: 'POST',
url: '/calendar/get_all_by_id/' + id,
}],
eventSourceSuccess: function(content, xhr) {
...
return events;
}
});
calendarEvents.render();
})
It's working properly.
The startParam option sets the name of the parameter which fullCalendar sends to the server for the start value, when fetching events. It doesn't set the value. The value which is sent is always the start date of the range which the user has just navigated to. You don't need to change that value yourself, and anyway it makes no sense to try and give it a fixed value - it is adjusted dynamically by fullCalendar every time events need fetching.
What are you actually trying to achieve with this code? Are you trying to change the current date on the calendar programmatically? If so then use https://fullcalendar.io/docs/Calendar-gotoDate

Calling function whenever full calendar view changes in Angular 8

I am using full calendar in my angular 8 app. Everything is working fine, but I want to call a function whenever the currentView of calendar changes. that is, I want to call a function/event whenever I change its view from month to week, or week to days.
For clarity, I want to detect view template changes (not date range changes). And by detecting it I want to highlight the button of respective current view.
This is my html code.
<p-fullCalendar #fc [events]="allEvents" [options]="options"></p-fullCalendar>
This is my .ts code
this.options = {
plugins: [dayGridPlugin, timeGridPlugin, interactionPlugin],
defaultDate: moment().toDate(),
themeSystem: 'yeti',
header: {
left: 'prev,next',
center: 'title',
right: 'dayGridMonth,timeGridWeek,timeGridDay'
}, dateClick: (e) => {
this.dateClicked(e);
}, eventClick: (e) => {
this.eventClicked(e);
},
}
In fullCalendar 4 you can use the viewSkeletonRender callback - this runs whenever a new view template is loaded.
viewSkeletonRender: function(info)
{
console.log(info); //replace with whatever code you need.
}

Events are duplicated when switching months in Fullcalendar v4

I'm using Fullcalendar v4 like this. Events are loaded correctly, but when I manually add a new one (it is also saved to SQL database via ajax call), then I change month and return back, this event is rendered twice. I'm not sure what cause this, because when I change months again, event is still doubled only, not trippled.
I've tried set lazyLoading or cache to false and also, for example, remove all events before rendering with $('.fc-event').remove(); but it did not help.
var calendar = new FullCalendar.Calendar(document.getElementById('calendar'), {
defaultView: 'resourceTimeline30',
views: {
resourceTimeline30: {
type: 'resourceTimeline',
duration: { days: 30 }
}
},
editable: false,
selectable: true,
resources: [ ... ],
events: 'https://www.example.com/?fullcalendar=load',
/*
// did not help
lazyLoading: true,
events: {
url: 'https://www.example.com/?fullcalendar=load',
cache: false,
extraParams: function() {
return {
cachebuster: new Date().valueOf()
};
}
}
*/
});
calendar.render();
So, if anybody needs it, according comments above, the working solution is:
Replace:
events: 'https://www.example.com/?fullcalendar=load',
With
eventSources: [{
'id': 1,
'url': 'https://www.example.com/?fullcalendar=load'
}],
And use that ID as second parameter in addEvent()
calendar.addEvent(event, 1);

Is it possible to email listWeek

Is it possible to send output to email instead of
<div id="fullCalendar" ></div>
after a full night, surfing the web, i cant find the solution, i'm no jquery programmer, so i realy hope some one can point me in the right direction
$(function() {
'use strict';
$('#fullCalendar').fullCalendar({
locale: 'nl',
defaultView: 'listWeek',
events: 'admin_app/kalender_load.php',
eventColor: '',
selectable:true,
selectHelper:true
});
});
$.post("email.php", { data : $("div#fullCalendar").html() }, function(result){
/* handle results */
});
I aspect to send the events from upcomming week true email,
but all i get is an empty mail
fullCalendar renders its content asynchronously - both the view and the events are rendered in separate asynchronous processes. You are trying to capture the content before it has been drawn (and in the case of the events, before the data has even been downloaded from your server).
You can use the viewRender callback to cause your code to wait until the calendar has been rendered.
Or if you need to include event data (which I guess you might) then you should use eventAfterAllRender instead, which waits until your events have been downloaded and drawn as well (this always occurs after the view has been rendered):
$(function() {
'use strict';
$('#fullCalendar').fullCalendar({
locale: 'nl',
defaultView: 'listWeek',
events: 'admin_app/kalender_load.php',
eventColor: '',
selectable: true,
selectHelper: true,
eventAfterAllRender: function(view) {
console.log($("div#fullCalendar").html())
$.post("email.php", {
data: $("div#fullCalendar").html()
}, function(result) {
/* handle results */
});
}
});
});
Demo: http://jsfiddle.net/baqdx94e/2/

Fullcalendar : disableResizing is only working on month view

I put three views in my fullcalendar : month, agendaWeek and agendaDay.
I need to activate drag & drop and forbidden events resizing.
I use this following solution to do that on each render event :
$("#calendar").fullCalendar(
'renderEvent',
{
title: "event name",
editable: true,
disableResizing: true
},
true
);
It's only working in the month view, that is I can drag & drop and resize events in agendaWeek and agendaDay views.
How can I remove resizing in this views ?
Thanks.
I try to use the calendar option durationEditable:false but it did not work. The workaround was to use CSS and hide the resize element:
.fc-resizer.fc-end-resizer {
display: none;
}
place eventStartEditable: false as shown here:
initialView: 'resourceTimeline',
slotMinWidth:1,
eventDurationEditable: false, // Disable Resize
eventStartEditable: false, // disable dreage drop
eventTimeFormat: {
hour: '2-digit',
minute: '2-digit',
hour12: true
},
Its Working,
for More
https://fullcalendar.io/docs/v1/disableResizing
disableResizing is available only as a global setting in FullCalendar. So if you want to disable resizing of all events in the calendar, you simply set the setting when you initialize FullCalendar:
var $calendar = $('#calendar').fullCalendar({
[...]
disableResizing: true,
[...]
});
If you want to disable resizing of specific events, you could take a look at this pull request.
place editable:false as shown here:
header:{
left:'prev,next today',
center:'title',
right: 'agendaWeek, list, rrule'//'month,agendaWeek,agendaDay'
},
editable:false, // place it under header. it worked for me
Works for Version 3

Categories

Resources