I would like to know if it is possible to block collision for events that are already stored in database. I am using an old database and adapting it for DHX Scheduler so there are some events that overlap and I don’t want that. For example, there are some events in DB that occur at the same time and they share their time slot in scheduler. The ideal solution would be to set priority of events, so the event with lower priority wouldn’t be shown, but randomly choosing which event to show would be fine too.
You can check collision when event is loaded, so if event’s timeslot is occupied event won’t be loaded into scheduler:scheduler.attachEvent("onEventLoading", function(data){
return !scheduler.checkCollision(data);
});You can add a priorities to do a more complex checkings, but the principle can be the same - returning ‘false’ from ‘onEventLoading’ will prevent loading a particular event.
I tried that, but then no event is shown at all. I even tried setting a connector with a sql query that only loaded one event, and it was detected as a collision.
I also tried blocking a timeslot with blockTime and then used
looks like there is an error in function description, function returns true if there is no collisions with other events. Try following code scheduler.attachEvent("onEventLoading", function(data){
return scheduler.checkCollision(data);
});
This works if I load a single event. But if I load a recurring event and one instance is colliding, the entire series is blocked. Is there any way to solve this?
Scheduler process the recuring serie as a single event, so it can’t block only part of it.
( it possible to alter data in db, and create exception record for some instance in recurring serie, but it need to be done on the server side )
So I will have to modify my DB and change events from recurring to individual? Or is there some other way?
Maybe you can help me easier with some context:
I have a DB with existing (read only) recurring events and I want to show these events and also allow users to add their own events which cannot collide with any other events. So far everything works great, but I also want to show holidays - I meant to do that with simply inserting a full day event on holidays, but as I described in my previous posts, standard collision preventing doesn’t work for me. Maybe I should approach this in an entirely different manner?
but I also want to show holidays
If this is the only feature which doesn’t allow to use the existing collision detection functionality, you can use marked time spans functionality. With it you can have some marked areas ( holidays ) which will be ignored by collision detection
DB and change events from recurring to individual? Or is there some other way?
You can have them as recurring with exceptions.
For example if you have two events, one for 5th day of each month, second for 1-10 days of this month, you have a collision. But you can add record to DB, which will instruct scheduler that for second event, occurence on 5th day must be ignored ( event will occurs on 1-4 and 6-10 ).