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

OnClientAppointmentMoveEnd fires twice

2 Answers 60 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Ei Wai
Top achievements
Rank 1
Ei Wai asked on 12 Aug 2014, 09:30 AM
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 Answers, 1 is accepted

Sort by
0
Dimitar Terziev
Telerik team
answered on 14 Aug 2014, 07:24 AM
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.

 
0
Ei Wai
Top achievements
Rank 1
answered on 19 Aug 2014, 07:54 AM
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
Tags
Scheduler
Asked by
Ei Wai
Top achievements
Rank 1
Answers by
Dimitar Terziev
Telerik team
Ei Wai
Top achievements
Rank 1
Share this question
or