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

How to show the different color for the different kind of activity

Asked by Rose
9 years ago.

Hello ,
I used daypilot month with sqlDatasource (ASP,Net C#) I have different kind of activity's status as Started , Closed and Canceled. I want to set activities which the status are Started with Green color and , Closed with Blue color and Canceled with Orange. But I dont know how to do it. Please provide me the guideline or suggestion.


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

You can use BeforeEventRender event handler:

protected void DayPilotMonth1_BeforeEventRender(object sender, DayPilot.Web.Ui.Events.Month.BeforeEventRenderEventArgs e)
  string status = (string) e.DataItem["status"];
  switch (status) {
    case "Started":
      e.BackgroundColor = "green";
    case "Closed":
      e.BackgroundColor = "blue";
    // ...

It assumes that the status is in "status" field of the data set returned by the SqlDataSource.

Comment posted by Rose
9 years ago.

Appreciated for your kindly help. Thanks s much

Answer posted by Sascha Basinski
9 years ago.

I have a timeline with events per Month (Monthly view is selected by startdate with a Combobox)
I have done this example and at start it works and my events were coloured, but...
when I change the month from one to another I get this error :
System.ArgumentNullException: The Value can not be Null. Parametername: container

Thanks Sascha

Comment posted by Sascha Basinski
9 years ago.

Sorry... here is my code...
Private Sub DayPilotScheduler1_BeforeEventRender(ByVal sender As Object, ByVal e As DayPilot.Web.Ui.Events.Scheduler.BeforeEventRenderEventArgs) Handles DayPilotScheduler1.BeforeEventRender
If e.DataItem.Item("EventID") = "K" Then e.BackgroundColor = "LightPink"
If e.DataItem.Item("EventID") = "U" Then e.BackgroundColor = "LightGreen"
If e.DataItem.Item("EventID") = "UH" Then e.BackgroundColor = "LightGreen"

End Sub

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