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

How to prevent appointment overlap?

16 Answers 346 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 27 Jan 2011, 05:30 PM
Hi,

    I'd like to prevent appointment overlap when Drag/Dropping appointments. Is there any suggestion on how I might achieve this?

Thanks,

Robert.

16 Answers, 1 is accepted

Sort by
0
Accepted
Valeri Hristov
Telerik team
answered on 27 Jan 2011, 05:38 PM
Hi Robert,

The First Look example of RadScheduleView for WPF contains a class named ConflictCheckingDragDropBehavior, where the requested functionality is already implemented. You can see how it works here:
http://demos.telerik.com/wpf/?ScheduleView/FirstLook

The behavior can be further extended to perform additional actions when the appointment is dropped over another appointment - for example to delete the underlying appointments, or ask the user what to do...

Kind regards,
Valeri Hristov
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Robert
Top achievements
Rank 1
answered on 27 Jan 2011, 05:45 PM
Fantastic! Thanks
0
Daniel
Top achievements
Rank 1
answered on 30 May 2011, 02:29 PM
Is there something like this also for the Silverlight version?
0
Valeri Hristov
Telerik team
answered on 30 May 2011, 03:24 PM
Hello Daniel,

The same example is available for Silverlight too:
http://demos.telerik.com/silverlight/#ScheduleView/FirstLook

Best wishes,
Valeri Hristov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Aziz
Top achievements
Rank 1
answered on 26 Sep 2011, 02:11 PM
you changed your online demo's recently and the new ones no longer have the ConflictCheckingDragDropBehavior.cs for WPF or silverlight, can you please provide these ASAP?
0
Yana
Telerik team
answered on 28 Sep 2011, 02:16 PM
Hi Jacob,

Please find ConflictCheckingDragDropBehavior.cs file attached.

All the best,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Aziz
Top achievements
Rank 1
answered on 05 Oct 2011, 03:14 PM
amazing, thanks so much!

on a related issue is there a way to easily add priority to each appointment so that if two appointments happen at the same time you can set which one has a higher priority and move that appointment to the left of the appointment block?
0
Yana
Telerik team
answered on 06 Oct 2011, 08:16 AM
Hello Jacob,

I'm afraid that this is not possible in RadScheduleView - there is no way to control the appointments' order in the timeslot.

We're sorry for the inconvenience.

Best wishes,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Patrick
Top achievements
Rank 2
answered on 25 Nov 2011, 11:38 PM
Hi Yana,

It is possible to have a full example in VB please?

Thank you in advance.
Patrick
0
Yana
Telerik team
answered on 28 Nov 2011, 04:25 PM
Hi Patrick,

I've attached the code in VB.

Greetings,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Patrick
Top achievements
Rank 2
answered on 29 Nov 2011, 01:02 AM
Hi Yana,

Thank you it's working good.

But with more than one Resources, I can't Resize or Drop my appointment if I already have another appointment (under an orther resources) at the same time.

I want to be able to control the overlapping on the same resource only...Is there a way to do it?

It's look like the    appointment.IntersectsWith(slot)    don't check the resource in the slot object but only the slot it self...

Thanks in advance!!!!

Public Class ConflictCheckingDragDropBehavior     
Inherits ScheduleViewDragDropBehavior     
    Public Overloads Overrides Function CanDrop(ByVal state As DragDropStateAs Boolean         
        Return state.DestinationAppointmentsSource.OfType(Of IAppointment)().Where(Function(a As IAppointmentNot state.DraggedAppointments.Contains(a)).All(Function(a As IAppointment) state.DestinationSlots.All(Function(s As SlotNot Me.AreOverlapping(a, s)))     
    End Function     
    Public Overloads Overrides Function CanResize(ByVal state As DragDropStateAs Boolean         
        Return state.DestinationAppointmentsSource.OfType(Of IAppointment)().Where(Function(a As IAppointment) a IsNot state.Appointment).All(Function(a As IAppointment) state.DestinationSlots.All(Function(s As SlotNot Me.AreOverlapping(a, s)))     
    End Function     
    Private Function AreOverlapping(ByVal appointment As IAppointmentByVal slot As SlotAs Boolean         
        Return appointment.IntersectsWith(slot)     
    End Function
End Class
0
Patrick
Top achievements
Rank 2
answered on 29 Nov 2011, 02:20 PM
Hi Yana,

I fix my problem that way....
Private Function AreOverlapping(ByVal appointment As IAppointmentByVal slot As SlotAs Boolean         
    If appointment.Resources(0).ToString <> slot.Resources(0).ToString Then             
        Return False         
    Else             
        Return appointment.IntersectsWith(slot)         
    End If     
End Function

Thank you
0
Grant
Top achievements
Rank 1
answered on 14 Dec 2011, 07:34 PM
Hi Yana--it appears that the attached code sample doesn't work well for recurring appointments 

Would you have a suggestion or updated sample on how to enable the same scenario with recurring appointments?

Thanks,
Grant
0
Yana
Telerik team
answered on 19 Dec 2011, 02:16 PM
Hi Grant,

Please modify AreOverlapping method in the ConflictCheckingDragDropBehavior like this:

private bool AreOverlapping(IAppointment appointment, Slot slot)
{
    return (appointment.IntersectsWith(slot) && AreIntersected(appointment.Resources.OfType<IResource>(), slot.Resources.OfType<IResource>())) ||
        (appointment.GetOccurrences(slot.Start, slot.End).Count() > 0 && AreIntersected(appointment.Resources.OfType<IResource>(), slot.Resources.OfType<IResource>()));
             
}

in order to make it work for recurrent appointments.

Hope this helps.

Greetings,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Julien
Top achievements
Rank 1
answered on 15 May 2013, 06:50 AM
I implemented the ConflictCheckingDragDropBehavior in my application. As expected, I can not overlap appointments. Good !

By cons, since i added this piece of code (see below), I noticed that it was possible to move an appointment in a read only slot, whereas before, it was impossible !

public class ConflictCheckingDragDropBehavior : ScheduleViewDragDropBehavior
{
        public override bool CanDrop(DragDropState state)
        {
            return state.DestinationAppointmentsSource
                .OfType<IAppointment>()
                .Where((IAppointment a) => !state.DraggedAppointments.Contains(a))
                .All((IAppointment a) => state.DestinationSlots.All((Slot s) => !this.AreOverlapping(a, s)));
        }
 
        public override bool CanResize(DragDropState state)
        {
            return state.DestinationAppointmentsSource
                .OfType<IAppointment>()
                .Where((IAppointment a) => a != state.Appointment)
                .All((IAppointment a) => state.DestinationSlots.All((Slot s) => !this.AreOverlapping(a, s)));
        }
 
        private static bool AreIntersected(IEnumerable<IResource> first, IEnumerable<IResource> other)
        {
            IEnumerable<IResource> firstResources = first
                .Distinct();
 
            IEnumerable<IResource> otherResources = other
                .Distinct();
 
            return firstResources.Where((IResource r) => otherResources.Contains(r)).Count() == firstResources.Count();
        }
 
        private bool AreOverlapping(IAppointment appointment, Slot slot)
        {
            return appointment.IntersectsWith(slot) && AreIntersected(appointment.Resources.OfType<IResource>(), slot.Resources.OfType<IResource>());
            return appointment.IntersectsWith(slot);
        }
}

I tried to modify the method CanDrop to handle the IsReadOnly property of the DestinationSlots but, strangely, this one always seems to be false.

Someone you already solved this problem ?
0
Julien
Top achievements
Rank 1
answered on 15 May 2013, 07:02 AM
I solved the problem by changing the CanDrop method like this :

return base.CanDrop(state) && state.DestinationAppointmentsSource
                .OfType<IAppointment>()
                .Where((IAppointment a) => !state.DraggedAppointments.Contains(a))
                .All((IAppointment a) => state.DestinationSlots.All((Slot s) => !this.AreOverlapping(a, s)));
Tags
ScheduleView
Asked by
Robert
Top achievements
Rank 1
Answers by
Valeri Hristov
Telerik team
Robert
Top achievements
Rank 1
Daniel
Top achievements
Rank 1
Aziz
Top achievements
Rank 1
Yana
Telerik team
Patrick
Top achievements
Rank 2
Grant
Top achievements
Rank 1
Julien
Top achievements
Rank 1
Share this question
or