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

How do I get an id of a recurring appointment

6 Answers 58 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Prava kafle
Top achievements
Rank 1
Prava kafle asked on 08 Aug 2013, 02:07 AM
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

6 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 08 Aug 2013, 10:46 AM
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.
0
Prava kafle
Top achievements
Rank 1
answered on 08 Aug 2013, 01:26 PM
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
0
Plamen
Telerik team
answered on 12 Aug 2013, 06:34 AM
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.
0
Prava kafle
Top achievements
Rank 1
answered on 12 Aug 2013, 05:21 PM
Thanks Plamen, I will try to use one of these properties.
0
Srivalli
Top achievements
Rank 1
answered on 24 Mar 2017, 01:52 PM
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.
0
Peter Milchev
Telerik team
answered on 29 Mar 2017, 09:11 AM
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 () 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.
Tags
Scheduler
Asked by
Prava kafle
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Prava kafle
Top achievements
Rank 1
Srivalli
Top achievements
Rank 1
Peter Milchev
Telerik team
Share this question
or