OnClientAppointmentMoveEnd fires twice

3 posts, 0 answers
  1. Ei Wai
    Ei Wai avatar
    56 posts
    Member since:
    Jul 2014

    Posted 12 Aug 2014 Link to this post

    Hi,

    I am using telerik version 2013.3.1324.35. I used scheduler with multiple resources. I use OnClientAppointmentMoveEnd to get the resource when they moved the slot. Below is the function I am using. It seems like function is calling twice. When first time fires, I can get the correct tutor. But on second time , it seems like it is getting the original tutor before moving. Is there anything I can do?  Thanks in advance.

    function OnClientAppointmentMoveEnd(sender, eventArgs) {
                   debugger;
                   var appointment = eventArgs.get_appointment();
                   var recurrState = appointment.get_recurrenceState();
                   var slotElement = $telerik.$(eventArgs.get_targetSlot().get_domElement());
     
                   $get('<%= hid_oldstart.ClientID %>').value = formatDate(appointment.get_start());
                   $get('<%= hid_oldend.ClientID %>').value = formatDate(appointment.get_end());
     
                   if (slotElement.is(".Disabled") || slotElement.parent().is(".Disabled")) {
                       eventArgs.set_cancel(true);
                   }
     
                 
                   // Calculate the duration of the appointment
                   var appointmentDuration = appointment.get_end() - appointment.get_start();
     
                   // The new start time is provided in the event arguments              
                   var newStartTime = eventArgs.get_newStartTime();
     
                   // Add the duration of the appointment to the new start time to get the new end time
                   var newEndTime = new Date(newStartTime.getTime() + appointmentDuration);
                   var editSeries = eventArgs.get_editingRecurringSeries();
     
                  
                   if (slotElement.is(".Disabled") || slotElement.parent().is(".Disabled") || slotElement.is(".ReasonDisabled") || slotElement.parent().is(".ReasonDisabled")) {
                       eventArgs.set_cancel(true);
                       radalert('Moving appointment to this slot is not allowed'
                           , 330, 180, 'Warning!', alertCallBackFn, imgUrl); return false;
                   }
                   else {
     
                       var list = appointment.get_attributes();
                       var attr = list.getAttribute('TutorID');
     
                       //debugger;
                       var targetResource = eventArgs.get_targetSlot().get_resource();
                       var newTutor = targetResource.get_key();
                       attr = newTutor;
                       var aptAttributes = appointment.get_attributes();
                       aptAttributes.removeAttribute("TutorID");
                       aptAttributes.setAttribute("TutorID", newTutor);
                       appointment.set_start(newStartTime);
                       appointment.set_end(newEndTime);
     
                       var state = appointment.get_recurrenceState();
     
                       $get('<%= hid_movedendStd.ClientID %>').value = formatDate(newStartTime);
                       $get('<%= hid_moveendEtd.ClientID %>').value = formatDate(newEndTime);
                       $get('<%= hid_moveendTutor.ClientID %>').value = newTutor;
                       //alert(newTutor);
     
                       var myarr = new Array();
                       myarr[0] = "movedend";
                       myarr[1] = formatDate(newStartTime);
                       myarr[2] = formatDate(newEndTime);
                       myarr[3] = newTutor;
                    alert(newTutor);
     
     
                       $find("<%=RadAjaxManager1.ClientID %>").ajaxRequest(myarr);
     
     
     
     
     
                      
                   }
                 
               }

    Best regards,
    Ei
  2. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 14 Aug 2014 Link to this post

    Hi,

    I have tried to reproduce the experienced issue, but to no avail. The AppointmentMoveEnd event is fired only once per move operation. Attached is the sample page I have tested with.

    Regards,
    Dimitar Terziev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ei Wai
    Ei Wai avatar
    56 posts
    Member since:
    Jul 2014

    Posted 19 Aug 2014 in reply to Dimitar Terziev Link to this post

    Hi,

    Thanks for the sample. I found out that it is because of my program bug. Thanks again for your kind assistance.

    Best regards,
    Ei
Back to Top