Automatically moving later events when inserting new event
Asked by David 9 years ago.
Is there a way to auto-shift future events when inserting a new event in between two events. The use case would be two events back to back where I then want to drag an event between them. I would like all remaining events on that resource to be shifted back in time corresponding to the duration of the new event.
Answer posted by Dan Letecky [DayPilot] 9 years ago.
This is a nice feature but it's not implemented at the moment because it would lead to bad app design (allowing inconsistencies).
1. Let's say you have scheduled one event per day for a given resource for the next year. When you display the current month in the scheduler and use this (hypothetical) feature to insert a new event in the middle it would shift all events that it knows about - i.e. events until the end of this month. It would leave all events from the following months unshifted.
2. Another thing - you don't want to rely on such a feature to be implemented purely on the client-side (the new dates need to be checked on the server side to prevent invalid input from being processed).
This means you have to re-implement it on the server side anyway. When you have the server-side implementation, you can simply send the updated events back and reload the Scheduler with the same effect.
Comment posted by David 9 years ago.
Thanks for the answer. I certainly understand the complexity that would go into this. We are looking to use this as a scheduler that would only schedule a week at a time. You are correct that I would have to implement this on the backend anyway, I was just hoping for a visual indication as to what is about to occur, by visually moving the items out during dragging. Thanks again for the help.
Comment posted by Dan Letecky [DayPilot] 9 years ago.
This is a poor replacement but you can use onEventMoving to provide a context-dependent hint to the user during dragging:
dp.onEventMoving = function(args) {
var existingEvents = args.row.events.forRange(args.start, args.end);
if (existingEvents.length > 0) {
args.right.html = "Existing events will be shifted";
args.right.enabled = true;
}
};
This is not an uncommon request and a better solution might come in the future but unfortunately it's not available at the moment.
Comment posted by David 9 years ago.
Just thought I'd share what I ended up coming up with. This will auto adjust the later events in the row after moving an event. It fits what I needed, and might be useful as a springboard for a future enhancement.