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

I Want to change Back Color of Appointment Condition Wise

2 Answers 248 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Chandan Kumar
Top achievements
Rank 1
Chandan Kumar asked on 15 Apr 2010, 09:18 AM
Dear Sir,
i m using Scheduler Control. I want to change Appointment Back Colour Condition Wise

In Appointment Template i Have a Label i have Just bound it to database and through This Label Value i want to Change Appointment Back Color.

Like If Label Value = "U" Then Appointment Color ="Red"
If Label Value = "P" Then Appointment Color ="Blue"
If Label Value = "A" Then Appointment Color ="Pink"

Like This. When i use Appointment Databound Event For Colour Changing Then How can i get Appointment Template Control Field Value on Appointment Databound.

And When i Use Appointment Created Event Then that Time Label Value Is Blank.

How Can I Achive this Problem.

Some Code Sample Like As


protected

 

void RadScheduler1_AppointmentCreated(object sender, AppointmentCreatedEventArgs e)

 

{

 

 

 

Label lblStatus = (Label)e.Container.FindControl("lblStatus");

 

 

 

 

if (lblStatus.Text == "U")

 

{

e.Appointment.BackColor = System.Drawing.

 

 

Color.Yellow;

 

}

 

 

 

else if (lblStatus.Text == "A")

 

{

e.Appointment.BackColor = System.Drawing.

 

 

Color.Blue;

 

}

 

 

 

else if (lblStatus.Text == "P")

 

{

e.Appointment.BackColor = System.Drawing.

 

 

Color.Green;

 

}

 

 

 

//checkbox1.Checked = true;

 

 

 

}



//////////////////////////////////////////////////////// aspx


<

 

telerik:RadScheduler AllowInsert="false" OnAppointmentDataBound="RadScheduler1_AppointmentDataBound" OnAppointmentCreated="RadScheduler1_AppointmentCreated"

 

 

 

 

 

runat="server" ID="RadScheduler1" Skin="Office2007" Height="551px" CustomAttributeNames="AppointmentStatus"

 

 

 

 

 

Width="690px" ShowFooter="false" SelectedDate="2010-03-18" DayStartTime="07:00:00"

 

 

 

 

 

DayEndTime="21:00:00" FirstDayOfWeek="Monday" LastDayOfWeek="Sunday" EnableDescriptionField="true"

 

 

 

 

 

ShowNavigationPane="false" OnAppointmentDelete="RadScheduler1_AppointmentDelete"

 

 

 

 

 

DataSubjectField="1" DataStartField="1" DataEndField="1" ShowAllDayRow="false"

 

 

 

 

 

OnClientAppointmentContextMenuItemClicked="A" OnClientAppointmentClick="ShowExisting1"

 

 

 

 

 

OnTimeSlotContextMenuItemClicked="RadScheduler1_TimeSlotContextMenuItemClicked" AllowDelete="false"

 

 

 

 

 

OnAppointmentContextMenuItemClicked="RadScheduler1_AppointmentContextMenuItemClicked"

 

 

 

 

onnavigationcommand="RadScheduler1_NavigationCommand">

 

 

 

 

 

<AppointmentContextMenuSettings EnableDefault="false" />

 

 

 

 

 

<TimelineView UserSelectable="false" />

 

 

 

 

 

<AppointmentTemplate>

 

 

 

 

<%

# Eval("Subject")%>

 

 

 

 

<asp:Label ID="lblStatus" runat="server" Text=<%#Eval("AppointmentStatus") %>></asp:Label>

 

 

 

 

 

</AppointmentTemplate>

 

 

 

 

<

 

TimeSlotContextMenuSettings EnableDefault="False" />

 

 

 

 

 

</telerik:RadScheduler>

 

 

 

 






Please Help Me.
Thanks
Chandan Kumar.

2 Answers, 1 is accepted

Sort by
0
Veronica
Telerik team
answered on 15 Apr 2010, 01:41 PM
Hello Chandan Kumar,

To be able to change the background color of the Appointments conditionally, you can simply use the custom attribute "AppointmentStatus" directly as follows:

protected void RadScheduler1_AppointmentDataBound(object sender, SchedulerEventArgs e)
   {
       switch (e.Appointment.Attributes["AppointmentStatus"])
       {
           case "U": e.Appointment.BackColor = System.Drawing.Color.Yellow;
               break;
           case "A": e.Appointment.BackColor = System.Drawing.Color.Red;
               break;
           case "P": e.Appointment.BackColor = System.Drawing.Color.Green;
               break;
           default:
               break;
       }
   }

In addition take a look at this blog post to see how to have any color appointments with rounded corners and gradients.


Cheers,
Veronica Milcheva
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Chandan Kumar
Top achievements
Rank 1
answered on 15 Apr 2010, 02:28 PM
Thank  you very Much Sir.
Tags
Scheduler
Asked by
Chandan Kumar
Top achievements
Rank 1
Answers by
Veronica
Telerik team
Chandan Kumar
Top achievements
Rank 1
Share this question
or