Drag Drop Behavior to popup Edit Appointment Dialog

5 posts, 2 answers
  1. Tim
    Tim avatar
    41 posts
    Member since:
    Oct 2012

    Posted 22 Feb 2013 Link to this post

    I'm trying to override the drag/drop behavior so that the appointment is not edited right when the drop occurs. I would like to popup the Edit Appointment Dialog that contains the new start/end times and require the user to fill in an additional field here. I do have a custom DragDropBehavior file but am not able to get it to work in this manner.

    Our business rules require that when rescheduling an appointment that we track the reason why it was rescheduled. If there is another way to ask the user this and track it, please let me know.

    Thanks
  2. Tim
    Tim avatar
    41 posts
    Member since:
    Oct 2012

    Posted 26 Feb 2013 Link to this post

    I can pop up the dialog box with the following code:

    public override void Drop(Telerik.Windows.Controls.DragDropState state)
            {
                base.Drop(state);
     
                LSLAppointment appt = state.Appointment as LSLAppointment;
     
                var scheduleView = state.ServiceProvider.GetService<IObjectEditor<IAppointment>>() as ScheduleViewBase;
                scheduleView.SelectedAppointment = null;
     
                RadScheduleViewCommands.EditAppointment.Execute(appt, scheduleView);
            }

    However, the OnAppointmentEdited event is still firing and I would like to bypass this event for a drag/drop and a resize. I'm using the OnAppointmentEdited event to save my appointment to my backend and I don't want to save the appointment on drag/drops until after the user clicks the button on the dialog box.

    Can I prevent the OnAppointmentEdited event from firing or can I determine that it was a drag/drop/resize in the OnAppointmentEdited event?

    Thanks

     

     

     


  3. DevCraft banner
  4. Answer
    Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 27 Feb 2013 Link to this post

    Hello,

    I am afraid that this is not possible. The AppointmentEdited event is fired when the appointment is edited, and that happens on drop.

    Regards,
    Konstantina
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  5. Tim
    Tim avatar
    41 posts
    Member since:
    Oct 2012

    Posted 27 Feb 2013 Link to this post

    Is there a way in the OnAppointmentEdited event to determine how it reached this point? Can I tell if it was dragged and dropped, resized or if they did it from the dialog box?

    Tim
  6. Answer
    Ivo
    Admin
    Ivo avatar
    390 posts

    Posted 04 Mar 2013 Link to this post

    Hi Tim,

    I believe that there is no way to find out this using the EventArgs provided by the event. However you can achieve this by writing some custom code into your custom DragDropBehavior. Using a flag to determine when the Appointment was edited by drag or resize operation can be easy. Here is sample code:
    public class CustomDragDropBehavior : ScheduleViewDragDropBehavior
    {
        public ScopeFlag IsDroppingOrResizing { get; set; }
     
        public CustomDragDropBehavior()
        {
            this.IsDroppingOrResizing = new SingleScopeFlag();
        }
     
        public override void Drop(DragDropState state)
        {
            using (this.IsDroppingOrResizing.BeginScope())
            {
                base.Drop(state);
            }
        }
     
        public override void Resize(DragDropState state)
        {
            using (this.IsDroppingOrResizing.BeginScope())
            {
                base.Resize(state);
            }
        }
    }

    private void OnRadScheduleViewAppointmentEdited(object sender, Telerik.Windows.Controls.AppointmentEditedEventArgs e)
    {
        var scheduleView = (RadScheduleView)sender;
        var customDragDropBehavior = (CustomDragDropBehavior)sv.DragDropBehavior;
        if (customDragDropBehavior.IsDroppingOrResizing.IsActive)
        {
            RadWindow.Alert("Changed by drag-drop/resize");
        }
        else
        {
            RadWindow.Alert("Not Changed by drag-drop/resize");
        }
    }

    In this example a class from Telerik's assemblies was use for the flag - SingleScopeFlag. However you can always use a simple boolean flag that is true while the drag or resize operation is happening.

    Regards,
    Ivo
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
DevCraft banner