search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Color ressource according status

Asked by Anonymous
4 years ago.

Dear all

i would like change color for only ressource with Maintenance Status.

//weekend color and maintenance
dp.onBeforeCellRender = function(args) {
if (args.cell.start.getDayOfWeek() === 0 || args.cell.start.getDayOfWeek() === 6) {
args.cell.backColor = "silver";

}

if (args.resource.status == "Maintenance") {
args.resource.backColor = "silver";

}

};

This code doesn't work. Ok for week-end but not for status.
Thanks a lot for your help

Answer posted by Dan Letecky [DayPilot]
4 years ago.

The row header background color needs to be set using onBeforeRowHeaderRender event. The onBeforeCellRender only sets properties of the grid cells.

It could look like this:

dp.onBeforeRowHeaderRender = function(args) {
  if (args.row.data.status === "Maintenance") {
    args.row.backColor = "silver";
  }
};

This assumes "status" is set on the resources[] items:

dp.resources = [
  { name: "Room 1", id: 1, status: "Maintenance" },
  // ...
];

See also:
https://api.daypilot.org/daypilot-scheduler-onbeforerowheaderrender/

Comment posted by Anonymous
4 years ago.

Yur code is ok for RowHeaderRender
Infact i would like change color for all ressource line

i have just check with this

dp.onBeforeCellRender = function(args) {
if (args.row.data.status === "Maintenance") {
args.row.backColor = "silver";
}
};

Comment posted by Dan Letecky [DayPilot]
4 years ago.

For cells you'll need to add this as well:

dp.onBeforeCellRender = function(args) {
  var row = dp.rows.find(args.cell.resource);
  if (row.data.status === "Maintenance") {
    args.cell.backColor = "silver";
  }
};
Comment posted by Anonymous
4 years ago.

Nice.

It's working.

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.