Hi, an am having difficulty getting a desired behavior when implementing drag and drop for appointments.
Form1
has
a) Scheduler1 (Storage1) - in Gantt view, resources are people/users
b) Grid1 - list of un-allocated tasks
c) custom control with Scheduler2 (storage2) - in day view, used for recording time against a "work log" item.
I'm part way there.
The user can drag a row from the gird onto either scheduler to create a new appointment (that works fine).
If the user drags an appointment from Scheduler1 to Scheduler2 (or vice versa) the appointment is created with missing "custom field" mappings, and it tries to delete the appointment from the source scheduler.
How can I implement a drag drop between 2 schedules and implement custom appointment creation as you do with the grid and not have it trigger that code when you are just moving the appointment around on its own scheduler (as the drag drop event fires for its own appointments as well as external drops coming in).
Any suggestions would be much appreciated.
Regards,
Joel
Implement Drag drop between 2 scheduler controls
Answers approved by DevExpress Support
Hi,
I'm afraid the SchedulerControl always removes appointments after moving them into another SchedulerControl. However, it is possible to implement this behavior manually via handling the AppointmentDrag, AppointmentsChanged and AppointmentDeleting events and preventing deleting of appointments in the AppointmentDeleting event handler. I've attached a sample project that illustrates this approach. Please review it.
As for custom field mappings, both your SchedulerControls should have the same mappings for custom fields and you need to set them manually. In this case you will be able to get a custom field in the second SchedulerControl. I've implemented this in my sample, too. You can set a breakpoint in the schedulerControl2_SelectionChanged method and see that appointments form the second ScedulerControl have a value in the CustomFields["Test"] property as their original appointments from the first ShcedulerControl.
Feel free to contact us if you need additional information.
Thanks
Hi,
CustomFields are copied with appointments. A sample from my answer shows this. I've also attached a video. Would you please provide me with a sample showing that CustomFields are not copied? It will help me find the cause of this issue. I am looking forward to your response.
Hi Alex, I can see in your project that the "test text" was indeed copied across.
It was when or the event I was checking for them, the Scheduler_AppointmentDrop event has the correct details but I needed to do some custom work on the Insert to fill out some other properties and the appointment passed into there was a new appointment without the values copied across yet.
I solved this by caching the Scheduler_AppointmentDrop(ed) object and used that on the insert event, works great.
Thanks for your reply
Hi,
Thank you for informing us that you have found a way to resolve the issue you mentioned.
Should you have any questions regarding our products or need our further assistance, do not hesitate to contact us.