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

AllowEventOverlapping on the basis of conditions.

Asked by nidhi
6 years ago.

I dont want overlapping for all the events i create, is there any way where i can specify my condition and if condition is true then only overlapping occurs else not.

Please reply for the solution.

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

You need to implement a custom rule using onEventMoving event handler - in the ASP.NET version it's accessible using EventMovingJavaScript property.

See also:
https://doc.daypilot.org/scheduler/event-moving-customization/

You can get a list of events for a given row using DayPilot.Row.events.all() method:
https://api.daypilot.org/daypilot-row-events-all/

There is also a helper method that will check an overlap of two date ranges - DayPilot.Util.overlaps():

function eventMoving(args) {
  var customCondition = args.row.id === "A"; // checking overlaps for row with id === "A" only
  if (!customCondition) {
    return;
  }
  var overlaps = args.row.events.all().some(function(e) {
    if (e.id() === args.e.id()) {  // the target can overlap with the source event
     return false;
    }
    return DayPilot.Util.overlaps(args.e.start(), args.e.end(), e.start(), e.end());
  };
  if (overlaps) {
    args.allowed = false;
  }
}
Comment posted by nidhi
6 years ago.

Thanks for the reply.
Actually In my case , i need TimeRangeSelectingJavascript="Selecting(args)";
And my problem is ,few parameters are available like -args.start, args.end but i need the args.text
basically for my condition.
Actually i have 2 types of events - one is appointment(created on timerangeselection)and other is blocked events.(on right click)
and I want overlapping should be allowed for appointment events and not for blocked events.
Once blocked events are created , i should not be able to give appointment event.

I hope you understand my need.
Please tell me how can i do this?

Comment posted by nidhi
6 years ago.

Hey please help. I am stuck.
I am using
TimeRangeSelectingJavascript="Selecting(args)";
when i am selecting / clicking a range then
1. I should get all the overlapping events for that range (how , pls tell me )
2. Iterating each event - if every overlapping event text contains some fixed Text(customised condition) then i should allow overlapping .
and if even the one of the overlapping events does not satisfy the condition then i should not allow overlapping.

Pls help me how can i do that?

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