AJAX Calendar/Scheduling Controls
I am trying to change the code to have the color coding for individual events when they are created by following the code changes mentioned in this thread
http://forums.daypilot.org/Topic.aspx/420/daypilot_lite__set_color_per_event
But still I am unable to get this to work.
I have the same problem.
Could you help me, please.
I know this is an old post but I thought I'd contribute to the knowledge community. I had a need for similar functionality. I needed to be able to change the event duration color or the event background color.
You have a couple of choices on how to implement this. The most basic thing you need to do is to modify the Event object to be able to take a BackColor and a DurationColor. This is in the Event.cs file. Simply add the following two variables:
public string BackColor;
public string DurationColor;
Then add a new Event constructor method that will accept the BackColor and DurationColor variables like this:
public Event(string pk, DateTime start, DateTime end, string name, string backcolor, string durationcolor, string resource) { this.PK = pk; this.PK = pk; this.Start = start; this.End = end; this.Name = name; this.DurationColor = durationcolor; this.BackColor = backcolor; this.Resource = resource; }
This is not all you need to do. You now need to go into the renderEvent method of the DayPilotCalendar.cs file and make sure you can set the correct colors. There is the following tag that will need to be modified. In my project it is on line 546 and you need to modify the following:
output.AddAttribute("onmouseout", "this.style.backgroundColor='" + (string.IsNullOrEmpty(e.BackColor) ? ColorTransform.ToHtml(EventBackColor) : e.BackColor) + "';event.cancelBubble=true;");
Then around line 556 you need to add:
output.AddStyleAttribute("background-color", string.IsNullOrEmpty(e.BackColor) ? ColorTranslator.ToHtml(EventBackColor) : e.BackColor);
finally to set the DurationColor you can set this on line 577
output.AddStyleAttribute("background-color", string.IsNullOrEmpty(e.DurationColor) ? ColorTranslator.ToHtml(DurationBarColor) : e.DurationColor);
That should allow you to start modifying the event colors based on the event. I have modified the Calendar Object to allow me to specify databound properties that will fill these values automatically but for brevity sake I'll leave those out of this response.
It is not too difficult to extend the Event object to allow for custom background colors or duration colors for the events. If you have questions just repond to this post.
Hi Bertman,
Is it possible to post the code for the pilot scheduler not calendar.
Another question do you have any idea on how to span the event across several resources, like calendar spans across several hours.
Thanks,
Vitor
The only way you are going to be able to 'span an event across multiple resources' is to create an event for each resource. This assumes you are using the open source version of the scheduler, but is probably true of the paid version too.
This is because an event can only have one resource. This will probably be ok for you most of the time, but if you run into a situation where your events are stacking, and therefore your resource row is doubled, it probably won't display in what you consider to be an ideal fashion.
DayPilot for ASP.NET WebForms, DayPilot for ASP.NET MVC, DayPilot for Java