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

Copying appointments (between resources)

1 Answer 37 Views
Scheduler and Reminder
This is a migrated thread and some comments may be shown as answers.
AMF
Top achievements
Rank 2
AMF asked on 08 Dec 2011, 09:01 PM

Hello!

I've been wanting to implement a copy function for appointments but I can't get it quite right.

The idea is simple, you have a form with a scheduler, which views multiple resources. When you start dragging and keep the control key pressed, you don't actually move the appointment but you copy it.

My code looks like this:

void rdSchedule_AppointmentDropping(object sender, AppointmentMovingEventArgs e)
        {
            if (ModifierKeys == Keys.Control)
            {
                if (e.Appointment is AmfAppointment)
                {
                    AmfAppointment copiedAppointment = ((AmfAppointment)e.Appointment).Copy();
                    copiedAppointment.Start = e.NewDate;
                      
                    this.rdSchedule.Appointments.Add(copiedAppointment);
                    e.Cancel = true;
                }
            }
        }

rdSchedule is the Scheduler control.

AmfAppointment is my own inheritance of an Appointment and Copy() is a function to duplicate the Appointment.

This only (seems to, still some bugs to work out) work for copying an appointment to the same resources.

When dragging the appointment to another resource nothing happens.

Also; the AppointmentMovingEventArgs has a NewDate but no NewResource (i.e.)? And the e.Appointment.ResourceId is the old ResourceId so I can't get it from there either.


What is the right approach here? And if so how can I make this work for copying between different resources as well?

Thank you!

1 Answer, 1 is accepted

Sort by
0
Ivan Todorov
Telerik team
answered on 13 Dec 2011, 03:17 PM
Hello Amf,

Thank you for contacting us.

This is happening because e.Appointment is not the same instance as the original appointment when you drag appointments between resources. This is an issue and it was reporter previously by one of our clients. Here is the PITS item about it. It describes a bit different issue, but it was caused by the same reason.

The issue will be addressed in the upcoming service pack which should be available for download next week. Also, a property called NewResourceId will be added to the event args so you can easily handle scenarios with grouped view. For the time being, I cannot provide you with a workaround due to the internal implementation of this functionality.

Should you have additional questions, do not hesitate to ask.

Kind regards,
Ivan Todorov
the Telerik team

Q3’11 of RadControls for WinForms is available for download (see what's new). Get it today.

Tags
Scheduler and Reminder
Asked by
AMF
Top achievements
Rank 2
Answers by
Ivan Todorov
Telerik team
Share this question
or