onEventCollision & recurring events

Hi,

I’ve been using the onEventCollision function, which, like it says, is triggered whenever multiple events are occupying the same time space. It also gets triggered when I press the ‘Save’ button when editing an event.

However, if I have a recurring event happening at (for example) 2-4pm, and I edit the details of an event which overlaps it, which pressing ‘Save’, the recurring event doesn’t come up as a colliding event.

Also, when creating a recurring event, it only runs the onEventCollision function for the first instance of the recurring event, not all of them.

How can I fix this?

Hi,
i couldn’t reproduce the problems with our samples,
can you attach a demo?

Sorry for the delayed reply.

shul.co.uk/diary/

To see what should happen:

  1. Create an event and select a location
  2. Create another event and select the same location
  3. Move one of the events so that it overlaps the other
  4. It won’t allow you to do that

Here’s how to reproduce the bug:

  1. Create an event and select a location
  2. Go to a previous week, on the same day at the same time as the first event
  3. Create a new weekly recurring event so that a future occurrence of it overlaps with the first event
  4. It will allow you to do that, and will have 2 events using the same locations at the same time (that shouldn’t happen).

It should stop you from creating a recurring event that overlaps with an event using the same location (it should run onEventCollision for each occurrence of the recurring event).

p.s. I’m fine to have the ‘no end’ option removed as I know that will make what I’m saying impossible to achieve.

Hi,
issue is related to your ‘onEventCollision’ handler. If you detach it, scheduler will check events correctly.
Currently handler returns ‘false’ when checking recurring events. that allows event collision
docs.dhtmlx.com/doku.php?id=dhtm … tcollision

Also, when creating a recurring event, it only runs the onEventCollision function for the first instance of the recurring event, not all of them.
Thats not quite right, it runs onEventCollision for the base event of the series. It contains rec_type and start/date of the whole series, you can parse it to get all occurences

Thanks for the response.

I’m not sure I worded it correctly.

I don’t want what you said, which is always returning true (therefore allowing no event overlap).
I want it to allow overlap if the 2 events use different locations.
That’s sorted out in my AJAX call.

I send over all of the colliding events, and if one of them shares a location with the edited event, you can’t edit that event. If none of them share a location, you can edit the event.

oEvents = ""; for(var i=0;i<evs.length;i++){ if(i != 0) oEvents += ","; oEvents += evs[i].id } $.ajax({ type: "POST", async: false, url: "spacesUsed.php", data: { eventID: ev.id, otherEvents: oEvents } }).done(function( msg ) { if(msg == "true"){ res = true; } else{ res = false; } }); return res;

I think the part that I don’t understand is your last comment.
How can I parse the rec_type to get all of the future events?
I don’t understand the rec_type format.

And also, how can I disable the ‘no end date’ option on the recurring setting?

How can I parse the rec_type to get all of the future events?
on the client you can use scheduler.getRecDates to get all instances of the recurringscheduler.attachEvent("onEventCollision", function (ev, evs){ if(ev.rec_type) var occurences = scheduler.getRecDates(ev.id);
docs.dhtmlx.com/doku.php?id=dhtm … etrecdates

And also, how can I disable the ‘no end date’ option on the recurring setting?
There is no config for this, but you can access html of recurring control and disable or hide that checkbox manuallyscheduler.attachEvent("onLightbox", function (){ var node = scheduler.formSection("recurring").node;//get DOM element of the control ... });

Thanks, that’s great!

Just one last question.

If I use scheduler.getRecDates(ev.id); in the onEventCollision function, and it turns out that all occurrences are fine apart from the one on 28/5/13, is there any easy way to edit the recurring dates to say ‘keep all dates apart from 28/5/13’?

It can’t be done through settings of events.
But after event saving, you can call

scheduler.deleteEvent("id#timestamp");

where

  • id - id of event
  • timestamp - start date of occurence which need to be delete as unix timestamp in seconds (new Date(some)).valueOf()/1000;
scheduler.deleteEvent("125#1364562835");

Thanks :slight_smile:

Is there anywhere where you explain how the recurring events are stored (what the format is)?

I need to load all of the dates with events on in PHP, and am trying to interpret the recurring events so that I can display the occurences of it, but can’t work out the format of it.
Any help would be really useful, thanks!

Hi,
here is some details about format
docs.dhtmlx.com/doku.php?id=dhtm … ntegration

Thanks!