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

Drag and Drop for Appiontment

5 Answers 131 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Oliver
Top achievements
Rank 1
Oliver asked on 06 Apr 2012, 08:03 PM
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?

5 Answers, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 10 Apr 2012, 09:34 AM
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.
0
Vijaianand
Top achievements
Rank 1
answered on 06 Jul 2012, 03:30 PM
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);
    }
0
Plamen
Telerik team
answered on 10 Jul 2012, 12:27 PM
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.
0
Vijaianand
Top achievements
Rank 1
answered on 12 Jul 2012, 12:45 PM
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.
0
Plamen
Telerik team
answered on 12 Jul 2012, 03:21 PM
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.
Tags
Scheduler
Asked by
Oliver
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Vijaianand
Top achievements
Rank 1
Share this question
or