search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Conditional Overlaps of Appointments?

Asked by mrplatypus (aka Dave)
7 years ago.

Hi Dan and Team,

I'm working on a project with daypilot.
Previously, I wanted to prevent all forms of overlaps - which was achieved.

A requirement has now come up to have conditional overlaps of appointments.
How would you recommend that this be achieved?

Thanks & Regards

mrplatypus (a.k.a. Dave)

Comment posted by mrplatypus (aka Dave)
7 years ago.

As a point to add:
The functionality is currently provided through the dayPilotScheduler control and there isn't any reason to change this.

Hope you can help.

Thanks & Regards

mrplatypus (a.k.a. Dave)

Answer posted by Dan Letecky [DayPilot]
7 years ago.

You can use the real-time event handlers to implement it:

  • EventMovingJavaScript
  • EventResizingJavaScript
  • TimeRangeSelectingJavaScript

The latest sandbox build (8.3.3582) supports DayPilot.Row.events.forRange(start, end) client-side method that you can use to find existing events in the row.

A quick example for event moving:

<DayPilot:DayPilotScheduler EventMovingJavaScript="moving(args)" ClientObjectName="dp" ... />

<script>
function moving(args) {
  // find events at the target position that block the location
  var events = dp.rows.find(args.resource).events.forRange(args.start, args.end).filter(function(e) { return e.id() !== args.e.id(); });
  if (events.length > 0) {
    args.allowed = false;  // block this location
  }
}
</script>

The filter() call above only removes the source event from the array. You'll need to modify the condition to also remove other events that don't block the target location.

You need to turn off the built-in overlap prevention feature (remove AllowEventOverlap="false").

Comment posted by mrplatypus (aka Dave)
7 years ago.

Dan and Team,

Thanks for replying, both by e-mail and on the forum...
I will investigate further to see if your suggestion helps my situation.

I'll leave the call open pending the results of my investigations.

Thanks

mrplatypus (a.k.a. Dave)

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.