How to prevent appointment overlap?

17 posts, 1 answers
  1. Robert
    Robert avatar
    3 posts
    Member since:
    Dec 2008

    Posted 27 Jan 2011 Link to this post

    Hi,

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

    Thanks,

    Robert.
  2. Answer
    Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 27 Jan 2011 Link to this post

    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>>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Robert
    Robert avatar
    3 posts
    Member since:
    Dec 2008

    Posted 27 Jan 2011 Link to this post

    Fantastic! Thanks
  5. Daniel
    Daniel avatar
    2 posts
    Member since:
    Apr 2011

    Posted 30 May 2011 Link to this post

    Is there something like this also for the Silverlight version?
  6. Valeri Hristov
    Admin
    Valeri Hristov avatar
    2252 posts

    Posted 30 May 2011 Link to this post

    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
  7. Aziz
    Aziz avatar
    32 posts
    Member since:
    Sep 2011

    Posted 26 Sep 2011 Link to this post

    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?
  8. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 28 Sep 2011 Link to this post

    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 >>

  9. Aziz
    Aziz avatar
    32 posts
    Member since:
    Sep 2011

    Posted 05 Oct 2011 Link to this post

    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?
  10. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 06 Oct 2011 Link to this post

    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 >>

  11. Patrick
    Patrick avatar
    31 posts
    Member since:
    Aug 2011

    Posted 25 Nov 2011 Link to this post

    Hi Yana,

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

    Thank you in advance.
    Patrick
  12. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 28 Nov 2011 Link to this post

    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 >>

  13. Patrick
    Patrick avatar
    31 posts
    Member since:
    Aug 2011

    Posted 28 Nov 2011 Link to this post

    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
  14. Patrick
    Patrick avatar
    31 posts
    Member since:
    Aug 2011

    Posted 29 Nov 2011 Link to this post

    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
  15. Grant
    Grant avatar
    13 posts
    Member since:
    Oct 2011

    Posted 14 Dec 2011 Link to this post

    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
  16. Yana
    Admin
    Yana avatar
    4554 posts

    Posted 19 Dec 2011 Link to this post

    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 >>

  17. Julien
    Julien avatar
    4 posts
    Member since:
    Nov 2012

    Posted 15 May 2013 Link to this post

    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 ?
  18. Julien
    Julien avatar
    4 posts
    Member since:
    Nov 2012

    Posted 15 May 2013 Link to this post

    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)));
Back to Top
UI for WPF is Visual Studio 2017 Ready