I want to display the sum of all events' value in the column header. This is my code for the week mode:
week: {
maxAllDayHeight: '100%',
allDayEvents: { autoHeight: true },
eventRenderer: eventRenderer,
columnHeaderRenderer: (dayCell: DayCell) => {
let sum = 0;
console.log(dayCell); //the log in the screenshot comes from this line
dayCell.events.forEach((event) => {
const val = event.getData('value');
sum += val;
});
return `${sum} `;
},
},
The allDay events were not returned by the columnHeaderRenderer function.
The column header value for the date 5/2/2025 in my screenshot should be 9, not 5.
Attachments
Screenshot 2025-05-07 145313.png (156.44 KiB) Viewed 471 times
The issue you're facing is likely because the columnHeaderRenderer function does not automatically include all-day events in the dayCell.events array. To include all-day events, you might need to access them separately. You can try checking if the dayCell object has a separate property for all-day events or adjust your logic to include them.
Here's a modified version of your code that attempts to include all-day events:
week: {
maxAllDayHeight: '100%',
allDayEvents: { autoHeight: true },
eventRenderer: eventRenderer,
columnHeaderRenderer: (dayCell: DayCell) => {
let sum = 0;
console.log(dayCell); // Log to check the structure of dayCell
// Sum regular events
dayCell.events.forEach((event) => {
const val = event.getData('value');
sum += val;
});
// Sum all-day events if they are stored separately
if (dayCell.allDayEvents) {
dayCell.allDayEvents.forEach((event) => {
const val = event.getData('value');
sum += val;
});
}
return `${sum} `;
},
}
If dayCell.allDayEvents does not exist, you may need to explore the structure of dayCell further to find where all-day events are stored.
Let me know if this helps or if you need further assistance!