[UWP]DragDrop exception

Hello,
using the new drag'n'drop feature in UWP app crashes with the following exception in case you navigate in week view during drag one week for/back and drop appointment then.
System.InvalidOperationException: Appointment Mapping cannot be a Null value
   at Syncfusion.SfSchedule.XForms.UWP.SfScheduleMapping.GetAppointmentRunTimeProperties(Object formsAppointmentObject, SfSchedule _formSchedule)
   at Syncfusion.SfSchedule.XForms.UWP.DependencyServices.EventsArgumentsHelper.GetDropEventArgsValue(SfSchedule nativeSchedule, SfSchedule formsSchedule, AppointmentDropEventArgs e)
   at Syncfusion.SfSchedule.XForms.UWP.ScheduleEventDependencyService.Native_AppointmentDrop(Object sen

Regards
P.S.: when navigating to new date, my AppointmentCollection is build new from database....

8 Replies

GC Ganeshamoorthy Chandramoorthy Syncfusion Team June 29, 2018 12:17 PM UTC

Hi Siggi, 
 
We have checked with the provided information. We are able to reproduce the Exception while dropping the appointment from one week to another week when new appointment collection is added on visible dates changed event. Currently, schedule supports to reset the appointment start time and end time using drag and drop operation. When new appointment collection is added in visible dates changed event, dragged appointment from old appointment collection is unable to change its start and end time and so, exception occurs. Could you please let us know whether you want to add dragging appointment in other collection when drag and drop the appointments? This would be helpful for providing better solution. 
 
Regards, 
Ganeshamoorthy C 



SI Siggi June 29, 2018 01:43 PM UTC

Hi Ganeshamoorthy,

I'm not quite sure if i get your question right. I try to explain what I want to do:
- start dragging  an appointment in one week and navigate to new week.
- drop the appointment at a timeslot
- when dropping, get the new start time/date and dragged/dropped appointment object, which contains additional info, like DB-ID etc..
I would update the underlying appointment data object in my DB, and rebuild the current appointment collection for that week.

Hopefully that helps to understand the problem, if you need more infos, let me know.
Regards





VR Vigneshkumar Ramasamy Syncfusion Team July 2, 2018 12:24 PM UTC

Hi Siggi,  
  
When appointment is dragged and dropped to new position, you can update the appointment data object in your DB by using AppointmentDrop event in the schedule control. You can get the dragged appointment details using Appointment property and new start date/time using DropTime property in AppointmentDropEventArgs. You can also obtain the new end date/time based on the dragged appointment duration. Kindly find the code snippet and sample below,   
   
Code snippet:   
schedule.AppointmentDrop += Schedule_AppointmentDrop  
…   
private void Schedule_AppointmentDrop(object sender, AppointmentDropEventArgs e)   
  
    var draggedAppointment = e.Appointment as ScheduleAppointment  
   
    //appointment duration   
    var duration = draggedAppointment.EndTime.Subtract(draggedAppointment.StartTime);   
   
    var newStartTime = e.DropTime  
    var newEndTime = e.DropTime.Add(duration);   
    //Based on the dragged appointment details, you can get the original appointment details from your DB    
    //And using new start time and end time you can update in your DB   
  
   
Sample: Sample   
  
Regards,   
Vigneshkumar R  



SI Siggi July 2, 2018 12:59 PM UTC

Hi Vigneshkumar,
thank you sharing the code example. That works, but the exception mentioned in my original post is still thrown..What about that?
Regards,
Siggi


SI Siggi July 3, 2018 10:02 AM UTC

Hi,
just FYI, I found an ugly workaround to avoid that exception.
When start dragging, I store the appointment in a temp variable, when the appointment collection is rebuild during visible dates changed event this appointment is added to the new collection. That is no problem, because after the drop the collection is build again (without the temp variable appointment, which is set to NULL during drop).
If have to test more to see if that brings any side effects.


GC Ganeshamoorthy Chandramoorthy Syncfusion Team July 3, 2018 05:12 PM UTC

Hi Siggi, 
 
As mentioned in our earlier update, currently, SfSchedule doesn’t support to drag and drop the appointments from one collection to another. When appointment is dragged and dropped to next week, exception is thrown due to the new appointment collection is set in visible dates changed event and dragged appointment from old appointment collection is unable to change its start and end time. As we mentioned in our previous update, you can handle AppointementDrop event and update appointments in DB. So, could you please confirm whether getting dragged appointment in AppointmentDrop event will be enough to achieve your requirement. 
 
Regards, 
Ganeshamoorthy C 



SI Siggi July 4, 2018 07:04 AM UTC

Hi Ganeshamoorthy,
As mentioned in my previous post, I found a workaround which seems to be OK for now.


VR Vigneshkumar Ramasamy Syncfusion Team July 5, 2018 12:54 PM UTC

Hi Siggi 
 
We are glad that you have found workaround to achieve your requirement. We have also considered to provide support to obtain the dragged appointment details in AppointmentDragOver event and AppointmentDrop event when appointment collection is changed in visible dates changed event and logged report for the same. Once this implementation is done, you can achieve your requirement based on the approach we have suggested in our previous update (updated on 7/2/2018). We will include this improvement in our upcoming volume 2 SP1 release which is expected to be available by end of month July 2018. We appreciate your patience until then.   
 
Regards 
Vigneshkumar R 


Loader.
Up arrow icon