This is a migrated thread and some comments may be shown as answers.

Change back-color of appointments based on a value

1 Answer 212 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Fazal
Top achievements
Rank 1
Fazal asked on 08 Feb 2011, 12:01 PM
hello everyone,
I have stuck on the issue of changing the background color of rad-scheduler appointments, based on a value. My scenario is as,
I have a class named as <appointments> which contains the following properties StartDate,EndDate,TaskId,TaskName and Status.
The appointments class is the data source of scheduler.
I want to change the background -color of appointments compairing the values in status field, but at the same time status should not be shown.
advance thnx.

scheuler.ascx
<telerik:RadScheduler ID="calTaskDisplay" runat="server" DataEndField="EndDate" DataKeyField="TaskId"
                    DataStartField="EndDate" DataSubjectField="TaskName" OnAppointmentCreated="calTaskDisplay_AppointmentCreated"
                    OnDataBound="calTaskDisplay_DataBound" AllowDelete="False" AllowEdit="False" SelectedView="MonthView"
                    DayStartTime="09:00:00" DisplayDeleteConfirmation="False" EditFormDateFormat="d/M/yyyy"
                    EnableAdvancedForm="False" EnableViewState="False" FirstDayOfWeek="Monday" LastDayOfWeek="Friday"
                    WorkDayEndTime="17:00:00" EnableCustomAttributeEditing="true" CustomAttributeNames="status"
                    WorkDayStartTime="09:00:00" OnAppointmentDataBound="calTaskDisplay_AppointmentDataBound">
                    <DayView DayStartTime="09:00:00" ShowHoursColumn="False" WorkDayEndTime="17:00:00" />
                    <WeekView DayStartTime="09:00:00" WorkDayStartTime="09:00:00" WorkDayEndTime="17:00:00" />
                    <AppointmentTemplate>
                        <%#Eval("Subject")%>
                        <input type="text" id="lblStatus" visible="false" title='<%# Eval("Status") %>' />
                    </AppointmentTemplate>
                </telerik:RadScheduler>

codebehind as,
scheduler.ascx.cs
Page_Load()
{
List<ScheduledTasks> loOtherTasks = loClient.GetScheduledTasks(Session["UserId"].ToString());
                calTaskDisplay.DataSource = loOtherTasks;
                calTaskDisplay.DataBind();
}
calTaskDisplay_AppointmentDataBound(object sender, SchedulerEventArgs e)
{
 switch (e.Appointment.Attributes["Status"])
            {
                case "Pending": e.Appointment.BackColor = System.Drawing.Color.Red;
                    break;
                case "pending": e.Appointment.BackColor = System.Drawing.Color.Red;
                    break;
                case "Complete": e.Appointment.BackColor = System.Drawing.Color.Green;
                    break;
                case "complete": e.Appointment.BackColor = System.Drawing.Color.Green;
                    break;
                case "Over due": e.Appointment.BackColor = System.Drawing.Color.Red;
                    break;
                case "over due": e.Appointment.BackColor = System.Drawing.Color.Red;
                    break;
                case "Started": e.Appointment.BackColor = System.Drawing.Color.Blue;
                    break;
                case "started": e.Appointment.BackColor = System.Drawing.Color.Blue;
                    break;
                default:
                    break;
}
 
calTaskDisplay_DataBound(object sender, EventArgs e)
{
foreach (ResourceType resType in calTaskDisplay.ResourceTypes)
            {
                resType.AllowMultipleValues = false;
            }
}

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 08 Feb 2011, 01:47 PM
Hello Fazal,


You can directly access the "status" value instead of adding it in AppointmentTemplate part.

Try the following code:
protected void RadScheduler1_AppointmentDataBound(object sender, SchedulerEventArgs e)
{
    DataRowView row = (DataRowView)e.Appointment.DataItem;
    string status = row["Subject"].ToString();
   // Now check for your condition
}



Thanks,
Princy.
Tags
Scheduler
Asked by
Fazal
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or