Recurring Event Popup

Using v14.2460 of SfSchedule, I am data binding a list of custom objects (events) using ItemsSource and ScheduleAppointmentMapping.  Listening to AppointmentEditorOpening and setting e.Cancel = true allows me to override the default editor window and replace it with my own, because AppointmentEditorOpeningEventArgs contains e.Appointment, a reference to the original bound item.

However, trying to override the editor in the case where the item is a recurring event (ie. RecurrenceRuleMapping != ""), fails miserably, as I am shown instead a pop up asking whether I would like to edit the single event or the entire series.  I need this to always expect the entire series, because it is only in this case that I get the original item.  How can I override this popup? 

Best case, I would like to write a custom dialog here.  If that's not possible, I would like this dialog to not appear, and for SfSchedule to always assume the value of 'entire series'.  

7 Replies

DY Deivaselvan Y Syncfusion Team August 22, 2018 06:12 AM UTC

Hi Ryan,

Thank you for contacting Syncfusion support.

Your requirement can be achieved by sample level, you can disable the popup showing “like to edit the single event or the entire series” by using PreviewMouseDoubleClick and PreviewMouseLeftButtonUp events of schedule instead of AppointmentEditorOpeningEventArgs, by assigning e.Handled as true for both the mentioned events. Appointment editor window will also have suppressed along with the popup and you can add your custom appointment editor and show the window in PreviewMouseDoubleClick event. Kindly refer the below code snippet and KB link,  
  
       schedule.PreviewMouseDoubleClick += Schedule_PreviewMouseDoubleClick;   
        schedule.PreviewMouseLeftButtonUp += Schedule_PreviewMouseLeftButtonUp;   
        …   
        private void Schedule_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)   
        {   
            e.Handled = true  
   
            //Custom appointment editor window   
            var window = new Window();   
            window.Show();   
        }   
   
        private void Schedule_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)   
        {   
            e.Handled = true  
        }   
  
 
Note:   
Schedule SingleClick and DoubleClick event will not be fired when e.Handled is assigned as true in PreviewMouseDoubleClick and PreviewMouseLeftButtonUp events of schedule.   

Regards,
Deivaselvan 



RD Ryan Downing August 22, 2018 03:54 PM UTC

That unfortunately won't work, as the mouse events don't give me the original item that I mentioned requiring.  Is there another way to access it?


DY Deivaselvan Y Syncfusion Team August 23, 2018 12:22 PM UTC

Hi Ryan,

In mouse click events, you can get the selected recurrence appointment by using OriginalSource property of MouseButtonEventArgs. Kindly refer the below code snippet. Based on the appointment you can handle the selection and the recurrence dialog.

Code snippet:  
        schedule.PreviewMouseDoubleClick += Schedule_PreviewMouseDoubleClick;  
        schedule.PreviewMouseLeftButtonUp += Schedule_PreviewMouseLeftButtonUp;  
  
        …                  
  
        private void Schedule_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)  
        {  
            if (this.CanHandleClick(e.OriginalSource))  
            {  
                e.Handled = true 
  
                //Custom appointment editor window     
                var window = new Window();  
                window.Show();  
            }  
        }  
  
        private void Schedule_PreviewMouseDoubleClick(object sender, MouseButtonEventArgs e)  
        {  
            if (this.CanHandleClick(e.OriginalSource))  
            {  
                e.Handled = true 
  
                //Custom appointment editor window     
                var window = new Window();  
                window.Show();  
            }  
        }  
  
        private bool CanHandleClick(object originalSource)  
        {  
            var appointment = (originalSource as FrameworkElement).DataContext asScheduleAppointment;  
  
            if (appointment == null 
                return false 
  
            if (!appointment.IsRecursive)  
                return false 
  
            return true 
        }     
  
In the above code snippet, you will get single recurrence appointment. Could you please confirm whether your requirement is to get the original recurrence appointment (provided in ItemsSource) to override the default editor window and replace it with your own? So that, it will be helpful for us to provide you better solution. 

Regards,
Deivaselvan 



RD Ryan Downing August 23, 2018 03:45 PM UTC

Yes, as I've mentioned, I require the original recurrence appointment.  The object from the original ItemsSource.  Not the ScheduleAppointment.  The DataSource from which the appointment is bound.  I need the original item.

I've seen a solution similar to the one you provided, and it is insufficient to my needs.


DY Deivaselvan Y Syncfusion Team August 27, 2018 12:07 PM UTC

Hi Ryan,

Thank you for the update.

As we mentioned in our previous update you can get selected recurrence appointment by using OriginalSource property of MouseButtonEventArgs. And you can get the parent recurrence appointment by comparing the RecurrenceID of selected recurrence appointment in ScheduleAppointemntCollection using Appointments property of SfSchedule. You can get the original recurrence appointment by comparing the ObjectID in ItemsSource of schedule. Kindly refer the below code snippet and sample for the same.

Code snippet:  
        private void Schedule_PreviewMouseLeftButtonUp(object sender, MouseButtonEventArgs e)  
         
            if (this.CanHandleClick(e.OriginalSource))  
             
                e.Handled = true 
                //Selected RecurrenceAppointment  
                var originalAppointment = this.GetCustomAppointment(e.OriginalSource);  
  
                //Custom appointment editor window       
                var window = new Window();  
                window.Show();  
             
         
  
        private object GetCustomAppointment(object originalSource)  
         
            var selectedAppointment = (originalSource as FrameworkElement).DataContext asScheduleAppointment;  
            var recurringAppointment = schedule.Appointments.FirstOrDefault(appointment => appointment.IsRecursive && appointment.RecurrenceID == selectedAppointment.RecurrenceID);  
  
            var source = (IEnumerable<object>)schedule.ItemsSource;  
            if (recurringAppointment != null 
                return source.FirstOrDefault(x => x.GetHashCode() == (int)recurringAppointment.ObjectID);  
  
            return null 
         

Sample: SfSchedule

Please let us know if you have any other questions.

Regards,
Deivaselvan 



RD Ryan Downing August 31, 2018 07:03 PM UTC

Yeah, that seems to do the trick.  It's not exactly ideal, but it'll do.  Thanks.


DY Deivaselvan Y Syncfusion Team September 3, 2018 11:47 AM UTC

Hi Ryan,

We are happy to know that the given solution helps you to achieve your requirement. Please let us know if you need any further assistance.

Regards,
Deivaselvan 


Loader.
Up arrow icon