Fix the event duration

Hi all.

I have been searching for a while and I couldn´t find anything.

Is there a way to fix the events duration.

For example: the events could not extend more than two hours or have a fixed duration of two hours.

Is there any way for doing this?

Thanks in advance and sorry if it is a explained in other place.

Cheers

Hi,
as I understand you need some validation rules to check or set event duration.
You can use “onEventSave” (changes made via lightbox), “onBeforeEventChanged” (changes made by drag’n’drop) events to check it or reset/set some new values.
docs.dhtmlx.com/scheduler/api__r … vents.html

Thanks for your answer SergeM.

I´m doing a check with the ‘OnEventSave’ event. So, when the lightbox is going to be saved, my function is fired. I compare the values of the dates, but the one I need is the end date value selected in the lightbox and I don´t know how to get this value :confused:

Any idea.

Thanks again.

Hi,
the “onEventSave” event receive 3 arguments:

  • id of the event;
  • data from the lightbox (including start/end date from time selectors);
  • “is_new” as “true” for the new event.

To get “old” properties (start/end dates) of the event use:

scheduler.attachEvent("onEventSave",function(id, data, is_new) { var old_ev = scheduler.getEvent(id); // you can get old start/end date var old_start = old_ev.start_date; var new_start = data.start_date; return true; });

Good explanation

Thank you very much.