Drag and Drop for Appiontment

6 posts, 0 answers
  1. Oliver
    Oliver avatar
    2 posts
    Member since:
    Apr 2012

    Posted 06 Apr 2012 Link to this post

    Hi, Telerik Team

    How to automatically change the start time and end time of appointment item to new value after moving the appointment item in telerik Scheduleview to new place?
  2. Plamen
    Admin
    Plamen avatar
    2730 posts

    Posted 10 Apr 2012 Link to this post

    Hi Oliver,

     
    You can handle the onClientAppointmentMoveStart and set the desired start and end time as it is set to 13-th of April in the code bellow:

    function OnClientAppointmentMoveStart(sender, args) {
               var start = new Date(2012, 3, 13, 11, 33, 0);
               var oneHourLater = new Date(2012, 3, 13, 12, 33, 0);
               args.get_appointment().set_start(start);
               args.get_appointment().set_end(oneHourLater);
               sender.updateAppointment(args.get_appointment());
               args.set_cancel(true);
           }

    Hope this will be helpful.

    All the best,
    Plamen Zdravkov
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Vijaianand
    Vijaianand avatar
    82 posts
    Member since:
    Jul 2012

    Posted 06 Jul 2012 Link to this post

    I tried the above code with some variations but its not working. Here is my code. I know I am making a silly mistake.
    function OnClientAppointmentMoveEnd(sender, eventArgs) {
            var apt = eventArgs.get_appointment();
            //alert(apt._start);
            var oldstart = apt._start;
            var oldend = apt._end;
            var newstart = eventArgs.get_newStartTime();
            //var newstart = eventArgs.get_newStartTime();
            eventArgs.get_appointment().set_start(newstart);
            eventArgs.get_appointment().set_end(oldend);
            sender.updateAppointment(eventArgs.get_appointment());
            eventArgs.set_cancel(true);
        }
  5. Plamen
    Admin
    Plamen avatar
    2730 posts

    Posted 10 Jul 2012 Link to this post

    Hello Vijaianand,

     I have inspected the code that you pasted. It seems that you are trying to change only the start of the dragged appointment and persist the "old End". This was working properly at my side in all case without those when the start time was set to be greater than the end time which is forbidden and is an expected error. Here is the code that I added in order to prevent the error:

    function OnClientAppointmentMoveEnd(sender, eventArgs) {
      
        var apt = eventArgs.get_appointment();
        //alert(apt._start);
        var oldstart = apt._start;
        var oldend = apt._end;
        var newstart = eventArgs.get_newStartTime();
        //var newstart = eventArgs.get_newStartTime();
        eventArgs.get_appointment().set_start(newstart);
        if (newstart < oldend) {
            eventArgs.get_appointment().set_end(oldend);
            sender.updateAppointment(eventArgs.get_appointment());
            eventArgs.set_cancel(true);
        }
    }

    Here you can see a video of my test as well.

    Hope this will be helpful.

    Greetings,
    Plamen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  6. Vijaianand
    Vijaianand avatar
    82 posts
    Member since:
    Jul 2012

    Posted 12 Jul 2012 Link to this post

    I did use your code and still having same issue. The appointment is not moving to the new location and it just pop's back to the old location. If you see your video, it does the same sometimes. When you drag and drop, it just pops back down the original but sometimes it works fine in the video but not for me.
  7. Plamen
    Admin
    Plamen avatar
    2730 posts

    Posted 12 Jul 2012 Link to this post

    Hi Vijaianand,

     
    This unusual behavior is most probably caused because you have not handled update event and this causes the appointments to reload instead of changing their start and end time.

    I am attaching a sample project that shows how should you bind a RadScheduler to ObjectDataSource in order to have a working drag and drop functionality.

    Hope this will be helpful.
     

    Kind regards,
    Plamen
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017