Getting the destination slot, when editing appointment

5 posts, 0 answers
  1. Sandi Markon
    Sandi Markon avatar
    101 posts
    Member since:
    Jul 2012

    Posted 17 Oct 2012 Link to this post

    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.
  2. Boyan
    Admin
    Boyan avatar
    758 posts

    Posted 22 Oct 2012 Link to this post

    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.

  3. DevCraft banner
  4. Syed Waqas
    Syed Waqas avatar
    5 posts
    Member since:
    Nov 2012

    Posted 08 Nov 2012 Link to this post

    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
  5. Boyan
    Admin
    Boyan avatar
    758 posts

    Posted 13 Nov 2012 Link to this post

    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.

  6. Syed Waqas
    Syed Waqas avatar
    5 posts
    Member since:
    Nov 2012

    Posted 13 Nov 2012 Link to this post

    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


Back to Top
DevCraft banner