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

Getting the destination slot, when editing appointment

4 Answers 99 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Sandi Markon
Top achievements
Rank 1
Sandi Markon asked on 17 Oct 2012, 11:45 AM
Hello.

I was wondering, if it is possible to get the destination slot, when being in scope of the AppointmentEditing event handler? I realize that this event is fired, when an appointment is about be edited/resized/..., but I would still like to know what the new date span is going to be.

Thanks in advance.

4 Answers, 1 is accepted

Sort by
0
Boyan
Telerik team
answered on 22 Oct 2012, 07:44 AM
Hello Sandi,

You can't get the destination slot in the AppointmentEditing event. I will advice you to use AppointmentSaving event instead, where you can get the new Start/End of the Appointment and still Cancel the action on some condition.

If this event is not suitable for your scenario, please provide some more information and we will be glad to help.

Kind regards,
Boyan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Syed Waqas
Top achievements
Rank 1
answered on 08 Nov 2012, 05:40 PM
i think he is asking to get other appointments occurances and stop adding more than N appointments for a slot, do you any example for that, i am after this for few days to prevent adding multiple appointments for a single slot in week view.
thanks
0
Boyan
Telerik team
answered on 13 Nov 2012, 05:56 PM
Hi Syed Waqas,

You can achieve this by attaching to AppointmentCreating event and then use the GettOccurences method. Here is some sample code that will Cancel the AppointmentCreating if there is already an Appointment in the time interval:
private void schedule_AppointmentCreating(object sender, AppointmentCreatingEventArgs e)
        {       
           var appointments = scheduleView.AppointmentsSource as ObservableAppointmentCollection;
           var allAppointments = new ObservableCollection<Occurrence>();
 
           foreach (var a in appointments)
           {
               allAppointments.AddRange(a.GetOccurrences(e.Appointment.Start, e.Appointment.End));
           }
          if (allAppointments.Count>1)
          {
          e.Cancel=true;
          }
        }

Hope this helps.

Greetings,
Boyan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Syed Waqas
Top achievements
Rank 1
answered on 14 Nov 2012, 05:10 AM
thanks for the example but i already achieved that, my control does not allow more than 1 appointment when creating or updating an appointment here is the code

 

private void sch_timesheet_AppointmentSaving(object sender, Telerik.Windows.Controls.AppointmentSavingEventArgs e)

{

 

ObservableCollection<MyAppointment> AllAppointments = sch_timesheet.AppointmentsSource as ObservableCollection<MyAppointment>;

e.Cancel = (

 

from a in AllAppointments where a.GetOccurrences(e.Appointment.Start, e.Appointment.End).Count > 0 && a.UniqueId != ((MyAppointment)e.Appointment).UniqueId select a).Count() > 0 ? true : false;

}

in AppointmentCreating or AppointmentEditing event you can not get the updated values of the returned appointment in AppointmentSavingEventArgs or AppointmentEditingEventArgs


Tags
ScheduleView
Asked by
Sandi Markon
Top achievements
Rank 1
Answers by
Boyan
Telerik team
Syed Waqas
Top achievements
Rank 1
Share this question
or