How do I get an id of a recurring appointment

7 posts, 0 answers
  1. Prava kafle
    Prava kafle avatar
    217 posts
    Member since:
    Apr 2010

    Posted 07 Aug 2013 Link to this post

    Hi,

    I have some recurring appointments in a Radscheduler, I am trying to get an id of an appointment and use it to process some other information.  appt.get_id() returns correct id for parent appointment(3610) or non recurring appointment. However, it returns "parentID_indexOfChildAppointment" (3610_1)for child recurring appointments(with id = 3611).

    How do I get exact id of child recurring appointment? I looked into Scheduler api and could not find any property for it.

     //Sets Appointment tooltip position
                  function clientBeforeShow(sender, eventArgs) {
                      var height = $telerik.$(sender.get_contentElement())[0].scrollHeight;
                      var width = $telerik.$(sender.get_contentElement())[0].scrollWidth;
                     
                     //Donot send request to webservice if tooltip is null and display subject/default text
                     var tooltip = Telerik.Web.UI.RadToolTip.getCurrent();
                     if (tooltip == null) {
                         SetToolTipPositionAndText(sender, sender._text);
                         return;
                     }

                      var element = tooltip.get_targetControl();
                      var appt = $find("<%=rsTicketsSchedule.ClientID %>").getAppointmentFromDomElement(element);
                      var apptID = appt.get_id();

    Thanks,
    Prava
  2. Plamen
    Admin
    Plamen avatar
    2926 posts

    Posted 08 Aug 2013 Link to this post

    Hi Prava,

     
    Basically the recurring appointments are generated on the fly based on the RecurrenceRule and that is why they are different from the other appointments. They exist in the DataBase and have their own id only if they are exceptions. That is why in such cases we recommend using the recurenceParendID instead of the id of the appointment.

    Hope this will explain the issue. 

    Regards,
    Plamen
    Telerik
    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 the blog feed now.
  3. Prava kafle
    Prava kafle avatar
    217 posts
    Member since:
    Apr 2010

    Posted 08 Aug 2013 Link to this post

    HI Plamen,

    I do not know whether these appointments are exceptions or created on the fly, I  am  only trying to add an enhancement to the work done by my co-worker. I will look into the code and try to find out.

    If it's an exception, how do I get it's id using javascript, is there any client side code for it?
    Else if its created on fly how do I get  recurrencePanelID  from domelement using javascript ? 


    Thanks for your quick response.
    Prava
  4. Plamen
    Admin
    Plamen avatar
    2926 posts

    Posted 12 Aug 2013 Link to this post

    Hi Prava,

     
    You can get the id as in the code below in case of occurrence:

    var apt = $find("RadScheduler1").getAppointmentFromDomElement(e.target);
                     var id;
     
                     if (apt.get_recurrenceState()== Telerik.Web.UI.RecurrenceState.Occurrence) {
                         id = apt.get_recurrenceParentID();
                     }
                     else {
                         id = apt.get_id();
                     }
                     alert(id);

    Hope this will be helpful.

    Regards,
    Plamen
    Telerik
    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 the blog feed now.
  5. Prava kafle
    Prava kafle avatar
    217 posts
    Member since:
    Apr 2010

    Posted 12 Aug 2013 Link to this post

    Thanks Plamen, I will try to use one of these properties.
  6. Srivalli
    Srivalli avatar
    9 posts
    Member since:
    May 2016

    Posted 24 Mar 2017 in reply to Plamen Link to this post

    If the recurring appointments are fly based how would we get the index number of the recurring series appointment. As a recurrenceparentID and appointID are the same.
  7. Peter Milchev
    Admin
    Peter Milchev avatar
    465 posts

    Posted 29 Mar 2017 Link to this post

    Hello Srivalli,

    For convenience and better visibility from the community, I will paste the suggestions from the support ticket.

    To check the index of an occurrence in the AppointmentClick event: 

    protected void RadScheduler1_AppointmentClick(object sender, SchedulerEventArgs e)
    {
        Appointment recurringAppointment = e.Appointment;
      
        var rrule = RecurrenceRule.TryParse(recurringAppointment.RecurrenceRule);
        if (rrule == null)
        {
            rrule = RecurrenceRule.TryParse(RadScheduler1.Appointments.FindByID(e.Appointment.RecurrenceParentID).RecurrenceRule);
        }
      
        rrule.Exceptions.Clear();
      
        var index = 0;
        var found = false;
        foreach (DateTime occurrence in rrule.Occurrences)
        {
            if (occurrence == e.Appointment.Start)
            {
                found = true;
                break;
            }
      
            index++;
        }
      
        if (found)
        {
            // the index variable is the zero based index of the clicked appointment
        }
        else
        {
            // the clicked appointment is an exception, would require custom logic to get the appointment index
        }
    }

    If an occurrence is deleted, the UpdateAppointment event of the master appointment will be fired. 

    One approach for this case is in the AppointmentUpdate event to parse the recurrence rules of e.Appointment and e.ModifiedAppointment. Then to use .Except() method (Difference between two lists) and get the new exception date. Then you can use the approach from the appointment click scenario.

    protected void RadScheduler1_AppointmentUpdate(object sender, AppointmentUpdateEventArgs e)
    {
        var ModifiedAppointmentRrule = RecurrenceRule.TryParse(e.ModifiedAppointment.RecurrenceRule);
        var AppointmentRrule = RecurrenceRule.TryParse(e.Appointment.RecurrenceRule);
      
        DateTime exception;
        if (ModifiedAppointmentRrule.Exceptions.Count > AppointmentRrule.Exceptions.Count)
        {
            exception = ModifiedAppointmentRrule.Exceptions.Except(AppointmentRrule.Exceptions).FirstOrDefault();
        }
        else
        {
            exception = AppointmentRrule.Exceptions.Except(ModifiedAppointmentRrule.Exceptions).FirstOrDefault();
        }
      
        if (exception != null)
        {
            // find the index of the appointment
        }
    }

    Regards,
    Peter Milchev
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top