Hi,
I would like to restrict the start and end at the original value during drag and drop appointment.
I just need to change the slot by dragging.
How can i do that.
thanks in advance.
7 Answers, 1 is accepted
Firstly, can you please review the Drag and Drop with RadScheduleView topic and the Drag and Drop WPF Demo if you didn't have the chance to do so already? If they do not help, may I kindly ask you to share some additional details regarding your requirement, as I am not sure I am understanding it completely?
Best Regards,
Stefan X1
Progress Telerik
Hi Stefan,
I have a situation where the appointments are actually Jobs in our operational system. Initially every appointment does not have a resource allocated to it, but we need to build a 'line of work' i.e. multiple jobs that will be assigned to the same resource. When we move these appointments (jobs) between lines (resources) we need to keep the time of the appointment i.e. it can not change times, only the resource that it is allocated to. So in a time-line view ideally the appointment should only be able to be moved up-down not left-right, but we would be happy to just drop and have it reset the start-end times to the original regardless of where on the line it was dropped.
What I can propose you is to utilize a custom DragDropBehavior. By doing so you should be able to implement the needed logic for restricting the drop operation through the CanDrop method. The approach of implementing such behavior is demonstrated in the Custom DragDropBehavior SDK Example. It can be reviewed through the SDK Samples Browser. Can you please take a look at it?
I hope this helps.
Regards,
Stefan
Progress Telerik
Hi Stefan,
If you try to restrict it via the CanDrop method then you have to move the mouse precisely vertically. If you move the mouse slightly to the left or right you get that it can't drop, our users are good but not that good.
What I ended up doing, is allowing drag anywhere BUT changing the time back to the original in the custom DragDrop.Drop method.
The following issues remain though in regards to UI behavior
1) while dragging the 'drag-cursor' moves (and displays the time of the slot it is being dragged over)
2) I am also checking for other appointments that overlap with this one, but once again unless you get the mouse precisely over the right spot, the methods to check the overlap fail (because it's using the current slot based on the drag position)
Is there any way that the 'drag-cursor' could remain in position and show the correct time, and thus (on a time-line view) basically only move vertically (up-down) in the appropriate time-slot.
Thanks
Craig
Thanks for the update.
I will go straight to your questions.
1. In order to control the position of the DragVisual, you can subscribe to the DragInitialize event. The event arguments provide the DragVisualOffset and the RelativeStartPoint properties through which you can achieve the desired behavior. The topic is discussed in greater detail in the DragVisual position relative to cursor forum thread. Can you please take a look at it and let me know whether it corresponds to your requirement?
2. As for avoiding the overlapping of the appointments, the approach is demonstrated in the Avoid Overlapping Appointments SDK Example. Can you please check it out?
Regards,
Stefan
Progress Telerik
Hi Stefan,
I have looked at the post, about subscribing to the DragInitialize event. But the RadScheduleView does not seem to trigger this event (with a custom drag-drop behavior or without one).
I have in code (the DragDropManager appears in the constructor of the window after InitializeComponent():
DragDropManager.AddDragInitializeHandler(ScheduleView, SvDragInitHandler);
private void SvDragInitHandler(object sender, DragInitializeEventArgs dragInitializeEventArgs)
{
Console.WriteLine(
$"Drag Start: X:{dragInitializeEventArgs.RelativeStartPoint.X} Y:{dragInitializeEventArgs.RelativeStartPoint.Y}");
Console.WriteLine(
$"Drag Offset: X:{dragInitializeEventArgs.DragVisualOffset.X} Y:{dragInitializeEventArgs.DragVisualOffset.Y}");
}
In the WPF, on the ScheduleView control I have added the code:
telerik:DragDropManager.AllowCapturedDrag="True"
So if I can't capture this event to start with, I can't go any further down that line.
Also my understanding from the article is that it gives an offset ultimately relative to the original, but I can't see how that can set say a static X (i.e. you can't move left-right) and keep a dynamic Y (you can move up-down). It appears that this just gives a relative point to the mouse cursor?
As the DragInitialize event is used internally as well, you need to mark the handledEventsToo parameter to true. Please, excuse me for missing to clarify this.
DragDropManager.AddDragInitializeHandler(ScheduleView, SvDragInitHandler,
true
);
Can you please give it a try?
As to your second question, indeed the RelativeStartPoint gives information regarding the relative coordinates of the mouse. I am afraid, that I cannot suggest a concrete implementation for achieving the desired calculation.
Regards,
Stefan
Progress Telerik