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

RadScheduler AppointmentDataBound is applying same color on all the appointmets

3 Answers 159 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Nirav
Top achievements
Rank 1
Nirav asked on 08 Mar 2012, 11:51 PM

Hi I am using radscheduler on my .net application,

I wanted to apply different color on my appointments depending upon the customized status field ,
RadScheduler_ AppointmentDataBound is applying same color on all the appointmets.

Below is my code:

protected

void RadScheduler1_AppointmentDataBound(object sender, SchedulerEventArgs e)

 

{

appointment = GetAppointments();

foreach (DataRow row in appointment.Rows)

{

statusValue = row["Status"].ToString();

switch (statusValue)

{

    case "1"
        
e.Appointment.BackColor = Color.Blue;

    break;

    case "2"
        e.Appointment.BorderColor = Color.Black;
    break;

    case "3":
        
e.Appointment.ForeColor = Color.DarkKhaki;

    break;

    default:
   break;

}

}

}


Can you please help me on that ?
Thanks.


3 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 12 Mar 2012, 05:53 PM
Hi Nirav,

 
You can get the "statusValue" row directly from the appointment as in the code bellow without using the GetApppintments() method:

protected void RadScheduler1_AppointmentDataBound(object sender, SchedulerEventArgs e)
    {
       
          string  statusValue = e.Appointment.DataItem.Row["Status"].ToString();
switch (statusValue)
{
    case "1":
        e.Appointment.BackColor = Color.Blue;
    break;
    case "2":
        e.Appointment.BorderColor = Color.Black;
    break;
    case "3":
        e.Appointment.ForeColor = Color.DarkKhaki;
    break;
    default:
   break;
}

Hope this will be helpful.

All the best,
Plamen Zdravkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Nirav
Top achievements
Rank 1
answered on 12 Mar 2012, 06:11 PM
Hi Plamen ,

Thanks for replying,
You are right but in my code i am not getting any intellisense after DataItem like DataItem.Row  .
Anyway i solved it by using the below code :

status = GetStatusByAppointmentId(appointmentId);

            if (status.Rows.Count > 0)
            {
                foreach (DataRow row in status.Rows)
                {
                    statusValue = row["Status"].ToString();
                    switch (statusValue)
                    {
                        case "1":  //Scheduled
                            e.Appointment.BackColor = Color.SkyBlue;
                            break;
                        case "2": //Happenned
                            e.Appointment.BackColor = Color.PeachPuff;
                            break;
                        case "3": //Didnt Happen
                            e.Appointment.BackColor = Color.Orange;
                            break;
                        default:
                            break;
                    }
                }
            }

But now i am getting one more issue :
When i will update my any appointments , it will apply default color to appointment (not any of the color from here.)
- it will require to refresh the page / then it will apply subsequent color from above cases.

is there any way that we can call AppointmentDataBound method , right after updating appointments.
I mean to say 
RadScheduler1_AppointmentUpdate
{
UpdateAppointment();

// something to call appointmetdatabound again ???
}


Thanks,
Nirav






0
Plamen
Telerik team
answered on 15 Mar 2012, 04:07 PM
Hi Nirav,

 
There is no way to trigger the AppointmentDataBound event in the AppointmentUpdate but you can add another Custom Attribute field where to point if an appointment has been updated and use its value when setting the colors in the AppointmentDataBound.

Hope this will help.

Greetings,
Plamen Zdravkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Scheduler
Asked by
Nirav
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Nirav
Top achievements
Rank 1
Share this question
or