Select Appointment

2 posts, 0 answers
  1. Richard
    Richard avatar
    32 posts
    Member since:
    Aug 2010

    Posted 20 Sep 2011 Link to this post


    I have been working on a function that allows a user to search for an appointment ID, and the appointment corresponding to the appointment ID is highlighted/selected.

    I have been able to do this by using the following:
    Dim appt As IEvent = Nothing
    appt = GetAppointment(CLng(msSearchID))
    If appt IsNot Nothing Then
       SchedulerUIHelper.SelectAppointment(radScheduler1, appt, True)
    End If
    Private Function GetAppointment(ByVal nID As Long) As IEvent
            Dim appt As IEvent = Nothing
                For Each a As IEvent In radScheduler1.Appointments
                    If a.UniqueId.KeyValue = CStr(nID) Then
                        appt = a
                    End If
                Return appt
            Catch ex As Exception
                Return appt
            End Try
    End Function

    However, an appointment which has a RecurrenceRule (a master appointment) is not being highlighted. Recurring Appointments are also not being highlighted, but this is understandable as radScheduler1.Appointments collection does not have separate instances of the recurrence, but it does have the master appointment.

    For example, an Appointment with ID 45 is a master appointment with 4 more appointments recurring daily. If the user enters 45, we select this appointment from the GetAppointment function as shown above, then pass it to SchedulerUIHelper.SelectAppointment to highlight this. The SelectAppointment method does not work, even though we pass the correct IEvent to it.

    Alternatively, if the user enters ID 33 (which is a normal appointment without any recurrence rule), then SelectAppointment function does work and the desired appointment is highlighted.

    Is this a bug in SchedulerUIHelper.SelectAppointment? If so, how do I implement the same functionality as the SelectAppointment function?

  2. Ivan Todorov
    Ivan Todorov avatar
    688 posts

    Posted 23 Sep 2011 Link to this post

    Hi Richard,

    Thank you for contacting us.

    The SelectAppointment method is not able to find the appointment that you have passed because when an appointment is defined as recurrent, the instance in the Appointments collection is not the one displayed. The occurrences are displayed instead (e.g. even the first displayed appointment of occurrence series is actually an occurrence - it is not the appointment that is stored in the Appointments collection).

    Here is a simple method which you can use in your case:
    Public Shared Sub SelectAppointment(scheduler As RadScheduler, appointment As IEvent)
        For Each element As AppointmentElement In SchedulerUIHelper.GetAppointmentElements(scheduler)
            If Object.Equals(element.Appointment, appointment) OrElse Object.Equals(element.Appointment.MasterEvent, appointment) Then
                SchedulerUIHelper.SelectAppointment(scheduler, element.Appointment, True)
            End If
    End Sub

    I hope this will help you. Feel free to write back if you have any further questions.

    All the best,
    Ivan Todorov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Back to Top