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

Appointment Resize - Client End Date Is Offset

1 Answer 46 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Marbry
Top achievements
Rank 1
Marbry asked on 21 Aug 2013, 02:52 PM
In the scheduler I'm using the timeline view and whole days.  When resizing an appointment start date it works fine.  When resizing the end date though it will offset it one day too far in the future.

So for instance if I have an appointment from 8/4 - 8/6, and I drag the end point to cover 8/7, the args.get_newEndTime() in the OnClientAppointmentResizeEnd event handler will return 8/8 not 8/7.

On the other hand, if I drag the start point of the same appointment the date reported by args.get_newEndTime() will still be the original value of 8/6.

This creates a problem since I don't see any way to detect in the OnClientAppointmentResizeEnd hander which end of the appointment is actually being resized.  The start and end dates on the appointment in args has already been changed.  Because of this I have to update both start and end dates when that occurs, which will in turn result an incorrect end date when the end point is resized vs. the start point.

Is there any way to detect in the OnClientAppointmentResizeEnd event handler which end of the appointment is being dragged so that I can account for this?  Or to get it to report the correct day?

ETA - the args._targetSlot._startTime will contain the correct date value for the target slot.  But there's still no way to tell for sure which end of the appointment is being resized.

1 Answer, 1 is accepted

Sort by
0
Marbry
Top achievements
Rank 1
answered on 21 Aug 2013, 07:48 PM
I think I finally determined how to do this, although it was buried.  This is in the OnClientAppointmentResizeEnd event handler.

var sourceSlot = new Date(sender._resizingState.sourceSlot._startTime);
var firstDay = new Date(sender._activeModel._owner._firstDayStart);
var targetDate = new Date(args._targetSlot._startTime);
var endDate = new Date(args.get_newEndTime());
var startDate = new Date(args.get_newStartTime());
 
if (sourceSlot.isSameDay(startDate) || sourceSlot.isSameDay(firstDay))
    endDate = targetDate;
 
PageMethods.ResizeItem_WM(featureID, startDate, endDate);


The ResizeItem_WM is a web method to update the DB with the altered appointment data.

Note that isSameDay() is from the DATEJS javascript date library.  If the end point is the one being dragged, the sourceSlot and startDate values will be on the same day, and we can apply the _startTime from the target slot to get the correct date.
Tags
Scheduler
Asked by
Marbry
Top achievements
Rank 1
Answers by
Marbry
Top achievements
Rank 1
Share this question
or