RadScheduler AppointmentDataBound is applying same color on all the appointmets

4 posts, 0 answers
  1. Nirav
    Nirav avatar
    5 posts
    Member since:
    Mar 2012

    Posted 08 Mar 2012 Link to this post


    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.


  2. Plamen
    Admin
    Plamen avatar
    3079 posts

    Posted 12 Mar 2012 Link to this post

    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.
  3. Nirav
    Nirav avatar
    5 posts
    Member since:
    Mar 2012

    Posted 12 Mar 2012 Link to this post

    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






  4. Plamen
    Admin
    Plamen avatar
    3079 posts

    Posted 15 Mar 2012 Link to this post

    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.
Back to Top