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

erronous endTime appointment moving

1 Answer 23 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Emrah
Top achievements
Rank 1
Emrah asked on 25 Sep 2013, 10:07 AM
Greetings,
I am using radscheduler's drag&drop facility to move appointments. i am using OnClientAppointmentMoving method for creating a javascript pop-up for confirmation which includes the old and new endTime for the appointment.
I am using eventArgs.get_targetSlot().get_endTime() method to retrieve the new endTime however the value I receive is 30 min after the beginning time no matter what. (There's no problem for the value of old begin/end times) Also the duration is always shown as 30 min even though the appointments vary between 3 to 4,5 hours.
below is the javascript method I am using for confirmation

function OnClientAppointmentMoveEnd(sender, eventArgs) {
                sender._dragging = false;
                var slot = eventArgs.get_appointment();
                var target = eventArgs.get_targetSlot();
                var msg = 'Please review assignment' + '\n' + '\n' +
                'Ticket: ' + slot.get_id().toString() + '\n' + '\n' +
                    'Current FE: ' + slot.get_resources().getResource(0)._text + '\n' +
                    'Current End: ' + slot.get_end().toString() + '\n' + '\n' +
                    'New FE: ' + target._resource._text + '\n' +
                    'New End: ' + target.get_endTime().toString() + '\n' + '\n' +
                    'Do you wish to proceed ?';
                if (!confirm(msg)) {
                    eventArgs.set_cancel(true);
                    slot.set_backColor('');
                    alert('Ticket reassignment cancelled');
                }
                sender._dragging = true;
            }

Any help is highly appreciated

Kind regards

1 Answer, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 30 Sep 2013, 07:04 AM
Hello,

I would like to clarify that the method eventArgs.get_targetSlot() retrieves the first time slot if the appointment lasts for more than a single time slot duration value. For example the default duration of a a time slot is 30 minutes. Let's assume that your appointment last for 1 hour ( 9am to 10am), which means that the appointment is "placed" over 2 time slots ( 1 hour is 2 x 30 minutes). If you move the appointment to start at 11 am, the eventArgs.get_targetSlot() will return the time slot that starts at 11am and ends at 11:30. Since user did not change the appointment duration (1 hour)  the appointment will start at 11 am and will end at 12pm. Therefore in order to determine when will be appointment new end time I would suggest the following approach:
  1. Retrieve the new start time of the dragged appointment - var newStartTimeTicks = eventArgs.get_newStartTime().getTime()
  2. Add the appointment duration  - var newEndTimeTicks = newStartTimeTicks + eventArgs.get_appointment().get_duration()
  3. Create a new Date object using the newEndTimeTicks variable. var appNewEndTime = var newEndTime = new Date(newEndTimeTicks )
Now the appNewEndTime will hold the new appointment end time as you expected.


Regards,
Boyan Dimitrov
Telerik
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 the blog feed now.
Tags
Scheduler
Asked by
Emrah
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Share this question
or