When I set the FullCalendar to:
JavaScript
x
2
1
initialView: 'dayGridWeek',
2
The Events are shown with coloured dots instead of solid fill (this is what I want). However, when I set the FullCalendar to:
JavaScript
1
2
1
initialView: 'timeGridWeek',
2
the Events appear as solid fill. How can I correct this please (i.e., show a coloured dot to the left of each Event)?
My code is:
JavaScript
1
36
36
1
var calendarEl = document.getElementById('calendar');
2
var calendar = new FullCalendar.Calendar(calendarEl, {
3
firstDay: 0, //Sunday
4
weekends: true, //Show the weekends
5
businessHours: { // days of week. an array of zero-based day of week integers (0=Sunday)
6
daysOfWeek: [ 1, 2, 3, 4, 5 ], // Monday - Friday
7
startTime: '09:00', // a start time
8
endTime: '17:00', // an end time
9
},
10
initialView: 'timeGridWeek',
11
headerToolbar: {
12
left: 'prev,next today',
13
center: 'title',
14
right: 'dayGridMonth,timeGridWeek,timeGridDay,listMonth'
15
},
16
locale: 'en-gb',
17
selectable: true, // gives ability to select multiple days and then have a callback event when this occurs
18
buttonIcons: false, // show the prev/next text
19
weekNumbers: true, // show week numbers
20
navLinks: true, // can click day/week names to navigate views
21
editable: true, // can make changes and add changes
22
dayMaxEvents: true, // allow "more" link when too many events
23
displayEventTime: false, // display the start time
24
displayEventEnd: false, // display the end time
25
eventTimeFormat: {
26
hour: '2-digit',
27
minute: '2-digit',
28
},// display time with minutes
29
eventDisplay: 'auto', //Controls which preset rendering style events use. 'block' - changes an event with start and end times from a list-item to a block
30
eventConstraint: {
31
start: moment().format('YYYY-MM-DD'),/* This constrains it to today or later */
32
end: '2100-01-01', // hard coded goodness unfortunately
33
},
34
35
events: responseJson1a,//Populate Sessions/Events using JSON
36
I have added the following from Kibé M.C:
JavaScript
1
7
1
eventDidMount: function (info) {
2
//you need to get the color from "info" argument and place it on the CSS style let eventColor = info."YourEventColor"
3
if (info.event) {
4
info.el.insertAdjacentHTML("afterBegin", '<p class="largeDot" style="color:${info.borderColor}">•</p>');
5
}
6
},
7
I also tried:
JavaScript
1
2
1
style="color:${info.event.borderColor}"
2
However the dot is not picking up the ‘red’ from borderColor and the text drops out of the border:
Also, the ‘month’ and ‘list’ views have two dots:
Advertisement
Answer
You can use eventDidMount
JavaScript
1
9
1
var calendarEl = document.getElementById('calendar');
2
var calendar = new FullCalendar.Calendar(calendarEl, {
3
4
eventDidMount: function (args: any) {
5
if (eventsExist) {
6
args.el.insertAdjacentHTML("afterBegin", "•");
7
}
8
},
9
UPDATE You should only see one dot.
Send a screenshot of the two dots so I try debugging the issue
You can add CSS to define a fixed size
To have dynamic colors on the dot, you can simply do this:
JavaScript
1
6
1
eventDidMount: function (info)
2
//you need to get the color from "info" argument and place it on the CSS style
3
let eventColor = info."YourEventColor"
4
{ if (info.event) { info.el.insertAdjacentHTML("afterBegin", `<p style="color:${eventColor}">•</p>`);
5
} },
6