onBeforeCellRender for a ressource on a day
Asked by eral57
10 years ago.
hi,
i want hilghting a specific day for a resource.
per example i have a scheduler for persons and a person is thick one day and i want put a color to visualize this evenement.
Answer posted by Dan Letecky [DayPilot]
10 years ago.
Let's say you have a list of days to be highlighted:
var days = ["2016-01-01", "2016-05-01"];
You can use the following code to highlight these days in the Scheduler:
dp.onBeforeCellRender = function(args) {
var highlight = DayPilot.list(days).map(function(src) { return new DayPilot.Date(src); }).some(function(day) { return day === args.cell.start.getDatePart(); });
if (highlight) {
args.cell.backColor = "#aaa";
}
};
Comment posted by Dan Letecky [DayPilot]
10 years ago.
And a modification for resource/day combination:
var list = [{id: "A", day:"2016-01-01"}, {id: "B", day: "2016-05-01"}];
dp.onBeforeCellRender = function(args) {
var highlight = DayPilot.list(list).map(function(src) { return {id: src.id, day: new DayPilot.Date(src.day)}; }).some(function(item) { return item.id === args.cell.resource && item.day === args.cell.start.getDatePart(); });
if (highlight) {
args.cell.backColor = "#aaa";
}
};
This question is more than 1 month old and has been closed. Please create a new question if you have anything to add.