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

RadScheduleView - Appointments Drag & Merge

15 Answers 257 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
m
Top achievements
Rank 1
m asked on 14 Mar 2017, 05:39 PM
Hi,

 

I'm developing a new feature with Schedule View, where  i need to add a drag & drop feature and allow merging two appointments if they are dragged over another.

Is it possible to acomplish that? I have an event - OnAppointmentSlotChanged - where I can re-schedule appointments, but how can i know if it is dragged over another appointment?

 

Thanks for any help that you can give,

Manuel

15 Answers, 1 is accepted

Sort by
0
Accepted
Yana
Telerik team
answered on 15 Mar 2017, 09:50 AM
Hi Manuel,

You will need to customize the DragDropBehavior of RadScheduleView in order to implement the needed functionality.  In short, you will have to override the Drop event, check whether there is an appointment in the destination slot, and if there is - update the needed properties according to the concrete requirements you have.

You could also check the following SDK samples which demonstrate different scenarios for customizing the drag-drop behavior of the control:
I hope this would be helpful.

Regards,
Yana
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
m
Top achievements
Rank 1
answered on 16 Mar 2017, 12:15 PM

Hi Yana,

 

Thanks for the links and the guidance, they were very helpfull and i can already detect when the user drags an event over another, and present a dummy message. Is it possible to return the two overlapping events to the viewmodel, where i need to aplly some logic to the merging process and is not correct to do it in the customized ScheduleViewDragDropBehavior.

 

Thank you and best regards,

Manuel  

 

0
Yana
Telerik team
answered on 17 Mar 2017, 10:26 AM
Hello Manuel,

I guess that you could raise an event from the DragDropBehavior and handle it in the ViewModel ( check Attached Events) - please have in mind that this is just an idea - I haven't tested it and I cannot refer you to any sample with RadScheduleView.

However,  why do you think it is not correct to implement the merging inside the DragDropBehavior - in the default behavior we're doing all the logic regarding the drag and drop of the appointments inside its events.

Let me know if I can be of further assistance.

Regards,
Yana
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
m
Top achievements
Rank 1
answered on 17 Mar 2017, 10:51 AM
Hi Yana


I was able to figure out a way, wich was to add a property on the appointment object "MergeWithAppointment" and then I get the source appointment and destination appointment, and apply the logic to merge the events.


I have another issue though.. In the schedule view, I use the day view display mode, and it is possible to have multilple appointments on the same slot.


I've used the code based on the examples you've suggested:


var hasNoIntersections = state.DestinationAppointmentsSource
   .OfType<IScheduledCollectionRunAppoinment>()
   .Where(appointment => !state.DraggedAppointments.Contains(appointment))
   .All(appointment => state.DestinationSlots.All(slot => ConflictChecking.AreOverlapping(appointment, slot, draggedOccurrence) == false ));

  
and


var appsInTheSlot = state.DestinationSlots.SelectMany(sl =>
    state.DestinationAppointmentsSource.OfType<IScheduledCollectionRunAppoinment>()
    .Where(a => a.IntersectsWith(sl) && !state.DraggedAppointments.Contains(a)));



Is there a better way to determine on wich effective appointment the mouse was released ??


Thank you very much,
Manuel
0
m
Top achievements
Rank 1
answered on 17 Mar 2017, 10:54 AM

Well , yes events are indeed a good ideia. I'll try it  and refactor my code :)

 

 

0
m
Top achievements
Rank 1
answered on 17 Mar 2017, 10:58 AM

[quote]why do you think it is not correct to implement the merging inside the DragDropBehavior - in the default behavior we're doing all the logic regarding the drag and drop of the appointments inside its events.[/quote]

I just think you just shouldn't mix UI logic with business logic. That's why i refer that is not a good ideia/practice put that on the custom drag&drop behaviour. :)

 

Thank you,

Manuel

0
Yana
Telerik team
answered on 22 Mar 2017, 09:53 AM
Hello Manuel,

Currently that's the only approach you can use in order to avoid overlapping appointments.

The provided code seems correct and I cannot tell why it does not work properly. I see that you're using custom Appointment, can you give us more details about it?

Regards,
Yana
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
m
Top achievements
Rank 1
answered on 22 Mar 2017, 03:40 PM

Hi Yana,

In fact, I want to "overlap" appointments. Imagine a scenario like this. I have the scedule view with several appointments and imagine that the appointments has a person assigned and tasks.

Appointment A ; Person X ; <Taks 1; Task 2>

Appointment B ; Person Y ; <Taks 3; Task 4>

For some reason, i want to assign tasks of appointment B to appointment A and to Person X.

The results would be:

     - Appointment B would dissapear from calendar

    - Appointment A would stay like this (Appointment A ; Person X ; <Taks 1; Task 2, taks 3, task 4>)

I want to achieve this via drag & drop.

The problem that I have now is that, uppon creation of appointments there can be two in the same slot, and when i drag an appointment to that slot (with two appointment), i want to know the correct appointment where i released the mouse button in order to do the merge of appointments (and tasks).

I guess that with this explanation, it made clearer my need. I will try to create a project, and yes, like you said I use custom Appointments.

Thank you, and I'll send the demo project as soon as possible.

Best regards,

Manuel

 

 

0
m
Top achievements
Rank 1
answered on 22 Mar 2017, 06:01 PM

Hi Yana,

Using your simple demo project i was able to create the scenario that i've described above. I hope you have understand, but in any question please ask.

Thank you for you help!

Best regards,

Manuel

 

P.S: I wasn't able to attach the project so i've placed in Onedrive here: https://1drv.ms/u/s!Av6irlZ-eF5OhHCGNcK9Qk_hYLwe

Please let me know if you have any problem.

0
Yana
Telerik team
answered on 23 Mar 2017, 08:34 AM
Hi Ðœanuel,

In this case you could use the TargetedAppointment property of the DragDropState as it holds a reference to the appointment the mouse is over when dropping the dragged appointment:

public override void Drop(DragDropState state)
{
     var targetAppointment = state.TargetedAppointment as Appointment;
      ....
}

I hope this will be helpful.

Regards,
Yana
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
m
Top achievements
Rank 1
answered on 23 Mar 2017, 10:19 AM

That would be just the perfect solution! But the version that I have installed doesn't currently has that property :(

 

// Type: Telerik.Windows.Controls.DragDropState
// Assembly: Telerik.Windows.Controls.ScheduleView, Version=2013.2.724.40, Culture=neutral

 

At this point it would be painfull to migrate/upgrade all controls and the risk associated is to high.

Is there a way to workarround this ? perhaps overriding ou extend with that property ?

Best regards,

Manuel

0
m
Top achievements
Rank 1
answered on 23 Mar 2017, 12:51 PM

Hi Yana,

 

Like you suggested, with the latest version of the controls works perfectly, but it is not possible for us, now, to upgrade controls.

Can we find a workarround? Suggest anything ?

 

Best regards,

Manuel

0
Yana
Telerik team
answered on 24 Mar 2017, 08:40 AM
Hi Manuel,

You can try the work-around suggested in the following forum thread where the same issue is discussed:
http://www.telerik.com/forums/drop-on-an-appointment

Basically it uses the VisualTreeHelper methods to find the element you're dragging over and thus gets the exact appointment you're about to drop on inside the destination slot.

Regards,
Yana
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
m
Top achievements
Rank 1
answered on 24 Mar 2017, 04:10 PM

Hi Yana,

That thread you've suggested, although is for silverlight, i did some research and was able do it in wpf. Can you take a look , to see if you suggest any improvment. It also makes my example available, hoping to help anyone.

Thank you very much,

Manuel

 

Once again, i wasn't able to attach the project here, so i've placed in 1Drive => https://1drv.ms/u/s!Av6irlZ-eF5OhHFO3jYEAJ5fcQFU

 

0
Yana
Telerik team
answered on 28 Mar 2017, 07:18 AM
Hello Manuel,

The solution you're using seems reasonable enough.
Of course, my recommendation is to consider upgrading to a more recent version of UI for WPF in order to use the built-in feature as well as other new functionalities.

Regards,
Yana
Telerik by Progress
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
ScheduleView
Asked by
m
Top achievements
Rank 1
Answers by
Yana
Telerik team
m
Top achievements
Rank 1
Share this question
or