This is a migrated thread and some comments may be shown as answers.

Drag Drop Behavior to popup Edit Appointment Dialog

4 Answers 98 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 23 Feb 2013, 01:14 AM
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

4 Answers, 1 is accepted

Sort by
0
Tim
Top achievements
Rank 1
answered on 26 Feb 2013, 05:44 PM

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

 

 

 


0
Accepted
Konstantina
Telerik team
answered on 27 Feb 2013, 02:43 PM
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.

0
Tim
Top achievements
Rank 1
answered on 27 Feb 2013, 03:00 PM
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
0
Accepted
Ivo
Telerik team
answered on 04 Mar 2013, 05:17 PM
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.

Tags
ScheduleView
Asked by
Tim
Top achievements
Rank 1
Answers by
Tim
Top achievements
Rank 1
Konstantina
Telerik team
Ivo
Telerik team
Share this question
or