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
12 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.

Thanks
Rose

Answer posted by Dan Letecky [DayPilot]
12 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";
      break;
    case "Closed":
      e.BackgroundColor = "blue";
      break;
    // ...
  }
}

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

Comment posted by Rose
12 years ago.

Appreciated for your kindly help. Thanks s much

Answer posted by Sascha Basinski
12 years ago.

Hello!
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

Why?
Thanks Sascha

Comment posted by Sascha Basinski
12 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 1 months old and has been closed. Please create a new question if you have anything to add.