Excuse me for posting this in this sub forum, I'm still on a trial version testing things out to see if Bryntum Calendar can work for me and I can't post in the Calendar forums anymore. Maybe someone can move this topic to the Calendar sub forum? Thanks.
I would like to know if I can set a default start time and end time for an event that is created by double clicking in the Month view or Agenda view. By default, the start time is 08:00 and the end time 09:00, but I would -for example- like to set it to 13:00:
Can this be done with the onEventCreated function?
Calendar doesn't seem to have a listener for beforeEventEditShow like Scheduler does (according to the docs at least), and also I would only want this for NEW events (not when editing another event that already has a set starttime/endtime).
Any help would be greatly appreciated!
Each mode
(child view) of a Calendar has this config option: https://www.bryntum.com/docs/calendar/api/Calendar/widget/mixin/CalendarMixin#config-autoCreate
To set common configurations for all modes in a Calendar, use this property on the Calendar: https://www.bryntum.com/docs/calendar/api/Calendar/view/Calendar#config-modeDefaults
Yes, I forgot, we import the autoCreate setting from the calendar into the views by default.
Non fractional startHour
is a bug. The code tries to set it, but the underlying date utility doesn't accept fractional hours
It asks for
DateHelper.set(dateStart, 'hour', autoCreate.startHour);
But DateHelper
doesn't cooperate. I will have to make it convert the hour to second and use
DateHelper.set(dateStart, 'second', autoCreate.startHour * 60 * 60);
Here is the ticket for this issue: https://github.com/bryntum/support/issues/4597
Thanks again for the response!
For a work-around, is there any way to programmatically set the starting time (hours and minutes) of an event under certain conditions?
E.g. if I change my resource combo menu value, can I automatically change the value of the starting time depending on the resourceId that's selected?
Something like (I don't know the exact correct syntax yet):
listeners:{
change(record){
// something like:
if (record.resourceId==1){
record.startTime= Date(something to set the time to 13:30...);
}
}
}
In Scheduler I managed to get something similar working, but in Calendar I couldn't get it to work...
You can listen for this event, and mutate the eventRecord
as you see fit: https://www.bryntum.com/docs/calendar/api/Calendar/view/Calendar#event-eventAutoCreated
Remember that if you dblclick in a DayView or WeekView, start time is included in the gesture (The user will click on the time required, and the autoCreate.step
will snap it to a boundary), so probably do not intervene if activeView.isDayView
(A WeekView is a DayView, but with 7 days)