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

Problem on update EndTime with resize

1 Answer 44 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
shahab
Top achievements
Rank 1
shahab asked on 26 Apr 2013, 07:07 AM
When I resize startTime of appointment it works but when I re-size endTime of appointment it does not work.
Current Time is 11:00 to 11:30. When I re-size startTime to 9:00 it works. Now Time is 9:00 to 11:30. But when I resize endTime to 14:00 e.ModifiecdAppointment still is 11:30!

1 Answer, 1 is accepted

Sort by
0
Plamen
Telerik team
answered on 01 May 2013, 07:04 AM
Hello shahab,

 
This seems to be an issue caused by the internal functionality of RadScheduler when its Global.asax file is overriden. You can overcome the issue by handling OnClientAppointmentResizeEnd client event and passing the new time to a hidden field as in the code below:

function OnClientAppointmentResizeEnd(sender,args) {
               var AppointmentResizeEndTime = document.getElementById("AppointmentResizeEndTime");
               var endTime = args.get_newEndTime().format("HH:mm");
               AppointmentResizeEndTime.value = endTime;
           }
 
       </script>
       <asp:HiddenField runat="server" id="AppointmentResizeEndTime" />
   <telerik:RadScheduler runat="server" ID="RadScheduler1"
protected void RadScheduler1_AppointmentUpdate(object sender, AppointmentUpdateEventArgs e)
   {
       TimeSpan span;
       string newEndTime = AppointmentResizeEndTime.Value;
 
       if (TimeSpan.TryParse(newEndTime, out span))
       {
 
           TimeSpan endTime = span;
           e.ModifiedAppointment.End = e.Appointment.End;
           e.ModifiedAppointment.End = e.ModifiedAppointment.End.Add(endTime - e.ModifiedAppointment.End.TimeOfDay);
       }
       TimeSpan startTime = e.ModifiedAppointment.Start.TimeOfDay;
       e.ModifiedAppointment.Start = e.Appointment.Start;
       e.ModifiedAppointment.Start = e.ModifiedAppointment.Start.Add(startTime - e.ModifiedAppointment.Start.TimeOfDay);
 
       if (e.ModifiedAppointment.Start > e.ModifiedAppointment.End)
       {
           e.Cancel = true;
           //TODO: Exceptio Handeling
           throw new Exception("start time must be before end time");
       }
   }

Hope this will be helpful. 

All the best,
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
shahab
Top achievements
Rank 1
Answers by
Plamen
Telerik team
Share this question
or