// Data that contains the information of which date needs to highlight
var highLightData = [
{ resourceIndex: 0, color: "yellow", date: new Date(2021, 2, 11) },
{ resourceIndex: 2, color: "red", date: new Date(2021, 2, 11) },
{ resourceIndex: 0, color: "yellow", date: new Date(2021, 2, 24) },
{ resourceIndex: 2, color: "red", date: new Date(2021, 2, 24) }
];
var dates = {};
var scheduleOptions = {
created: (args) => {
// Converting the data that contains the color details as the time based object
for (let i = 0; i < highLightData.length; i++) {
var time = highLightData[i].date.getTime();
var index = highLightData[i].resourceIndex;
if (!dates[time]) {
dates[time] = [];
dates[time][index] = highLightData[i].color;
} else if (dates[time] && !dates[time][index]) {
dates[time][index] = highLightData[i].color;
}
}
},
renderCell: (args) => {
if (args.elementType === "monthCells") {
var time = args.date.getTime();
// Checking the current rendering cell dates is available or not in the generated data
if (dates[time] && dates[time][args.groupIndex]) {
// Changing the background color of the cell based on the data
args.element.style.background = dates[time][args.groupIndex];
}
}
}
};
var scheduleObj = new ej.schedule.Schedule(scheduleOptions, '#Schedule'); |