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

Drag and drop and snap to predefined time

1 Answer 72 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Håkan
Top achievements
Rank 1
Håkan asked on 15 Jan 2014, 12:16 PM
Hi there!

I'm building a staffing application.
I have a ScheduleView with a DayViewDefinition. Outside of the schedule I have a ListBox with appointments that are predefined in time.
The user drag an appointment and drop it on the schedule on a specific person (it's grouped on resources).
The appointment will now be saved on that person with the predefined time, regardless of where in time it was dropped.

This works fine for me, since I don't care about where it is dropped.
But it looks strange to the user, since he can drop the appointment at for example 8:00 AM, but it actually ends up at 9:00 AM.
Is there any way I can snap the appointment to the predefined time when I'm dragging it over the schedule?


Regards,
Håkan

1 Answer, 1 is accepted

Sort by
0
Kalin
Telerik team
answered on 17 Jan 2014, 02:10 PM
Hi Håkan,

You could achieve the desired behavior using the ScheduleView DragDropBehavior. You could either override the CanDrop method in order to check if the DestinationSlot is the required one and if not to prevent the drop. Or you could modify the already dropped Appointment by overriding the DragDropCompleted method and change the Start and the End of the Appointment as required. Here is a sample solution of the second scenario:

public override void DragDropCompleted(DragDropState state)
{
    var appointment = state.Appointment as CustomAppointment;
    var scheduleView = state.ServiceProvider.GetService<IDialogProvider>() as RadScheduleView;
 
    scheduleView.BeginEdit(appointment);

      // set the required times
    appointment.Start = appointment.Start.AddHours(1);
    appointment.End = appointment.End.AddHours(1);
    scheduleView.Commit();
 
    base.DragDropCompleted(state);
}

Hope this helps.

Regards,
Kalin
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
ScheduleView
Asked by
Håkan
Top achievements
Rank 1
Answers by
Kalin
Telerik team
Share this question
or