Color of events

Hi, this has been asked for, but honestly I didn’t get it at all.

I just looked at your example : samples/02_customization/01_events_coloring.html

I added a new field (“employee”)to my “events” table, it contains an employee’s username related to that single event. So far, so good. I also have a table called “employees” which contains all usernames and hex colors, meaning, each username has a unique color.

How can i color all events that employee XXXXX has created with his unique color?

Thank you very much.

a) you need to add the styles for each employee

<style> .dhx_cal_event.empXX div{ background-color:YY; } </style>

where XX - id of employee, YY - color value

b) in js code

scheduler.templates.event_class=function(start,end,event){ return "emp"+event.employee; }

Thanks again for your reply Stanislav.

What if I want to get the colors dynamically? There are too many employees and they are always hiring new ones.

Regards.

I think I got it, any doubt I’ll bother you again :slight_smile: Thank you for taking the time to respond

What if I want to get the colors dynamically?
If you have limited list of colors - you can define css classes for colors not for employee’s ID
Also, you can generated css classes dynamically ( original code of 01_events_coloring.html creates css classes for random colors on the fly )