I need the element start and end time and the target resource after dragging it to a new position.
Your examaple: http://demos.telerik.com/kendo-ui/scheduler/restriction works quite well, but only if using the "moveEnd" event handler .
It seems that when registering kendoDropTargetArea, its "drop" event handler overwrites the "moveEnd" event handler of the scheduler.
The problem is that the object "e" as recieved by the drop doesnt have start, end and resources.
example:
scheduler.view().content.kendoDropTargetArea({
filter: ".k-scheduler-table td, .k-event",
drop: function(e){
// get start, end and resource
}
});
$("#scheduler").kendoScheduler({
..
moveEnd: function(e){
// never gets here
}
});
5 Answers, 1 is accepted
You could try the followoing approach:
drop: function(e){ //get start, end and resource var offset = $(e.dropTarget).offset(); var slot = scheduler.slotByPosition(offset.left, offset.top); var startDate = slot.startDate; var endDate slot.endDate; }dojo example
Regards,
Anton
Telerik by Progress
That returns not the element start and end dates, but the slot ones.
I already red in this thread http://www.telerik.com/forums/drag-drop-external-item-onto-scheduler that "I'm afraid this is not supported out of the box."
So it seems i need to calculate that alone playing with the relative position of the selected element and the dropTarget
I managed to create a sample solution with very slight deviation
// get the view scaling valuesvar tick = scheduler.view().options.majorTick;var columnWidth = scheduler.view().options.columnWidth;var widthTickFactor = tick / columnWidth; // represents how many minutes fit in one pixel // get the selected element position /_schedulerDraggedElementUID is set on drag start/var selectedOffset = $( "div[data-uid='" + _schedulerDraggedElementUID + "']" ).offset()// get the drop positionvar dropOffset = $(e.target).offset(); // calc new start time /el.ui.start is the previous start time taken from the scheduler datasource/var offDiff = selectedOffset.left - dropOffset.left;var timeDiff = offDiff * widthTickFactor;var newStartTime = moment(el.ui.start).subtract(timeDiff,"minutes").format("YYYY-MM-DD HH:mm:ss")
That i guess would only work, because dragging the element doesnt scroll the scheduler view.
Is it actually possible to make the view scrollable while dragging the element?
It seems I misunderstood what you have meant. Indeed this is a custom scenario and as mentioned in the forum post it is not supported out of the box. The view is actually scrollable if you use the scroll while dragging the event.
Regards,
Anton
Telerik by Progress