Problem on update EndTime with resize

2 posts, 0 answers
  1. shahab
    shahab avatar
    58 posts
    Member since:
    Mar 2009

    Posted 26 Apr 2013 Link to this post

    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!
  2. Plamen
    Admin
    Plamen avatar
    3079 posts

    Posted 01 May 2013 Link to this post

    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.
Back to Top