Scheduler "BeforeAppointmentDelete" Event

Posted by: tyler.wesche on 8 October 2018, 3:49 am EST

    • Post Options:
    • Link

    Posted 8 October 2018, 3:49 am EST

    I’m currently working on a wpf app that uses the scheduler control from C1.WPF.Schedule.4. According to the documentation that i found for this version, i should be able to intercept a delete command with the “BeforeAppointmentDelete” event, however no such event appears to exist as part of the class.

    I need to have a step between the user clicking the delete button and the schedule being deleted for them to enter a reason that the appointment is being deleted. Is there some other way to isolate the delete event before the appointment is actually deleted?

  • Posted 8 October 2018, 2:33 pm EST

    Hello Tyler,

    For this purpose, you can use the UserDeletingAppointment event. For more information on this event and its arguments, please refer the following link:

    http://help.grapecity.com/componentone/NetHelp/c1wpfschedule/webframe.html#C1.WPF.Schedule.4~C1.WPF.Schedule.C1Scheduler~UserDeletingAppointment_EV.html

    Thanks,

    Ruchir

  • Posted 9 October 2018, 12:03 am EST

    So that’s what i’m currently attempting to use but here’s the issue: Since “Deleting” occurs while the controls inherent delete functionality is already happening, the appointment still gets deleted from the control. I can’t seem to preempt the record deletion based on a user’s selection.

    My apologies if i’m just not fully understanding the functionality of these controls. I’m working through a previous developer’s unfinished project trying to get it working.

  • Posted 9 October 2018, 2:48 am EST

    The alternative I’ve been researching is to make a custom EditAppointmentTemplate so that i can directly control the behaviors. If this sounds like a better way could you point me towards some documentation on the correct format for replacing the template in WPF? I have found an old Silverlight example that i’m using to get a general idea for the equivalent Non-Silverlight implementation but some of the intricacies escape me. Sorry to jump around a bit. On a very tight schedule.

  • Posted 9 October 2018, 2:53 pm EST

    Hi,

    Since “Deleting” occurs while the controls inherent delete functionality is already happening, the appointment still gets deleted from the control.

    To cater this, you can set e.Handled to true based on some condition, like:

    private void sched1_UserDeletingAppointment(object sender, C1.WPF.Schedule.AppointmentActionEventArgs e)
    {
        if(e.Appointment.Importance== ImportanceEnum.Normal)
        {
            e.Handled = true;
            System.Diagnostics.Debug.WriteLine("Appointment Delete Handled");
        }
    }
    ```Hopefully this would meet your requirement and you won't need to customize anything.
    
    Regards,
  • Posted 10 October 2018, 7:30 am EST

    Unfortunately it does not. I’ve already gotten most of the way through creating the custom control at this point. The only remaining point of confusion for me is how/if i am able to capture the dialog response out of the Scheduler EditAppointmentDialog without throwing it into a window control. Here’s a few snips of my code with any proprietary data removed to try and help

    Main page scheduler:

    
    <c1:C1Scheduler Name="PTScheduler" ViewType="Day" AllowDrop="True" Grid.Column="1" HorizontalAlignment="Stretch" Margin="0" Drop="PTScheduler_Drop" Padding="0" EditAppointmentTemplate="{StaticResource customEditAppointmentTemplate}"
                                AllDayAreaHeight="0" AppointmentChanged="PTScheduler_AppointmentChanged" UserAddingAppointment="PTScheduler_UserAddingAppointment" VerticalContentAlignment="Stretch" 
                                SelectedAppointmentChanged="PTScheduler_SelectedAppointmentChanged" UserEditingAppointment="PTScheduler_UserEditingAppointment" 
                                BeforeAppointmentResize="PTScheduler_BeforeAppointmentResize" LayoutUpdated="PTScheduler_LayoutUpdated" NextAppointmentText="Next Shipment" 
                                PreviousAppointmentText="Previous Shipment" UserDeletingAppointment="PTScheduler_UserDeletingAppointment"   PreviewKeyDown="PTScheduler_PreviewKeyDown" IsInPlaceEditingDisabled="True" IsTabStop="False">
     
    

    Code within the main window - Appointment Changed Event. I am attempting to prevent the appointment change from scheduling when the user drags it unless they enter a “reason” in the custom EditAppointmentDialog control.

    
                    //If within valid working hours
                    if (!InvalidTimes)
                    {
                        PTScheduler.EditAppointmentDialog(e.Appointment);
                        // I want to get the response from the dialog here. 
                        
                        //If response = OK (Save)
                        AutoSave();
                    }
    
    
  • Posted 11 October 2018, 1:06 am EST

    Hello,

    As I understand, you want that when end-user makes any change through edit appointment dialog, you want to detect those changes. And based on this, you want to save/not save etc

    In that case, you do need to create custom edit appointment dialog and instead show it is as modal window. So, when the user ends editing the appointment you would still be in the event and be able to access the new appointment values and accordingly perform conditional operations.

    Thanks,

    Ruchir

  • Posted 11 October 2018, 8:15 am EST

    Yes that is the end goal. Do you have any up to date documentation/examples for this? Even the one in the WPF documentation that i found earlier is Silverlight Based instead of just WPF.

  • Posted 12 October 2018, 12:00 am EST

    Hi Tyler,

    Please search your ComponentOne install folder for the product sample CustomDialogs sample (\Documents\ComponentOne Samples\WPF\C1.WPF.Schedule\CS\CustomDialogs). It contains many customized Scheduler dialogs along with their source code, you can copy the code and xaml and edit it according to your needs.

    Thanks,

    Ruchir

  • Posted 12 October 2018, 12:31 am EST - Updated 4 October 2022, 12:13 am EST

    Unfortunately there is no such folder… Where can i download it?

  • Posted 14 October 2018, 3:59 pm EST

    Hi,

    WPF samples folder is not present in your machine, which means the ComponentOne product samples for WPF did not install over your machine. To install them, I would suggest you to re-install ComponentOne WPF edition.

    Mean-while, you can access the CustomDialogs product sample using the following page:

    https://www.grapecity.com/en/samples/customdialogs-1

    Regards,

    Ruchir

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels