Limit the number of events per day

Hi,

Is there a way for me to limit the number of allowed events per day?
Or failing that allow only one event per calendar day?

Thanks very much for the support!

Elliot

Check
docs.dhtmlx.com/doku.php?id=dhtm … llisions&s[]=collision

You can use code like

scheduler.config.collision_limit = 2; //allows 2 events per a time slot

Hello,

If you really need to block cases where one day (say 2011-11-16) would have two events are totally different time (01:00 - 02:00, 05:00 - 06:00) then you need to attach your own handler for the onEventSave event.
And there:

  • get date for the saved event
  • try to get events for that date (not time)
  • if there are such event - block saving, else - allow it

Kind regards,
Ilya

Thanks ever so much for your quick response!
Really appreciated :smiley:

Here is the code I used to limit number of events starting at the same day:

[code]scheduler.attachEvent( “onEventSave”, function( id, e ){
var ed;

for( var ek in this._events ) {
	
	if( id == ek )
		continue;
	
	ed = this._events[ ek ];

	if( sameDay( ed.start_date, e.start_date ) ) {
		alert( 'You may not add more than one event per day' );
		return false;
	}
}

return true;

} );

function sameDay( d1, d2 ) {
if( d1.getDate() != d2.getDate() ) return false;
if( d1.getFullYear() != d2.getFullYear() ) return false;
if( d1.getMonth() != d2.getMonth() ) return false;

return true;

}
[/code]