CalendarMixin
Configs
39
Configs
39A key to use to activate this view.
This is optional and defaults to the first letter of the title property.
The title defaults to the mode name, so by default, the activation key is the first letter of the mode name.
Configure this as false to disable drag-creating events in this view.
Configure this as false to disable drag-moving events in this view.
Configure this as false to disable drag-resizing events in this view.
By default, when navigating through time, the next time block will be animated in from the appropriate direction.
Configure this as false to disable this.
{"gesture":"dblclick","newName":"L{Object.newEvent}","step":"15 minutes","snapType":"round","duration":"1 hour","startHour":8}Also a propertyIf this config is set, then the gesture configured (which defaults to dblclick) creates a
new event at the mouse or touch event's time point.
The exact time is rounded to the closest specified step value. This value is also used
for the step value in the EventEdit's
time input field.
The duration of the created event is the specified duration value.
If this is specified as true, the gesture becomes dblclick, and the other properties
are the default values listed below.
If this is specified as a string, the string becomes the gesture, and the other properties
are the default values listed below.
| Parameter | Type | Description |
|---|---|---|
gesture | String | The DOM event name which initiates event creation at the event's position. |
newName | function | String | The name of an event created using
|
step | String | The time unit by which to snap the start click point of auto created events.
Only for views which have a granularity of less than one day such as For views which show whole days, the start defaults to 8am. This is a string in the format required by parseDuration. This value is also used for the step value in the EventEdit's time input field. |
snapType | round | ceil | floor | How to snap a precise gesture time to a boundary specified by the |
duration | String | The default start hour for auto created events in the form accepted by parseDuration |
startHour | Number | The default start hour for auto created events
in views where the time granularity is one day. In a This is the hour of the day to start the event at. It may be fractional. |
Options to add into scroll options when the scrollTo method is called.
By defult, scrolling is animated.
To make the scrolling animate with easing and highlight the target element, configure the view with
{
defaultScrollOptions : {
highlight : true,
animate : {
duration : 750,
easing : 'bounce'
}
}
}
A function that provides the textual description for this view. If provided, this function overrides the descriptionFormat.
descriptionRenderer() {
const
{
startDate,
endDate
} = this,
sameMonth = startDate.getMonth() === endDate.getMonth(),
sd = DateHelper.format(startDate, sameMonth ? 'DD{->}' : 'DD/MM/YYY{ -> }'),
ed = DateHelper.format(endDate, 'DD/MM/YYY');
return `${sd}${ed}, ${this.L('L{eventCount}', this.eventCount)}`
}
| Parameter | Type | Description |
|---|---|---|
view | CalendarView | The active view in case the function is in another scope. |
Description string
The durationUnit to use when drag-creating events in this view.
For DayViews, this is normally 'hour', for views with a granularity
level of one day, the default is 'day'.
Configure this as null to have drag-create use the unit of the duration property of
the autoCreate config as the duration unit when drag-creating events.
The height of event bars if this view creates event bars.
MonthView, CalendarRow (the all day row in a WeekView) and AgendaView use this config.
In DayView and WeekView,
the event element's height is part of the widget's layout and signifies the event's duration,
so these use a default value of 'auto'.
A function which compares events which some views use to decide upon rendering order.
Default sorter function are provided from the EventSorter class.
A custom sort function may be configured.
Note that the two objects to compare may either be EventModels
or EventBars which contain an eventRecord property which is the EventModel.
| Parameter | Type | Description |
|---|---|---|
lhs | EventModel | EventBar | The left side value to conpare |
rhs | EventModel | EventBar | The right side value to conpare |
By default, the end date of an all day event is displayed in the UI as the last calendar date on which the event falls. For most end users, this is the expected value.
Technically, the endDate is a timestamp
which represents the exact point in time at which an event ends. To use this instead,
configure extendAllDayEndDay as true.
To be clear, this would mean that an allDay event starting and ending on the 7th of February 2020, would show the end date in the tooltip as 8th of February 2020.
Configure as true to hide nonWorkingDays
The maximum date to which the endDate of this view may be navigated.
The minimum date to which the startDate of this view may be navigated.
Non-working days as an object where keys are day indices, 0-6 (Sunday-Saturday), and the value is true.
Defaults to nonWorkingDays.
The class name to add to events which have an end date in the past. Defaults to 'b-past-event'.
There are no CSS rules attached to this class. You may use it to style past events.
Configure as true to make the view read-only, by disabling any UIs for modifying data.
For example, the event editor will be set to read-only and will not allow changes to be made. And the EventMenu will not show options which can mutate the events.
Note that checks MUST always also be applied at the server side.
Path to load resource images from. Used by the showResourceAvatars config to create URLs using the resource's image or imageUrl fields:
imagerepresents image name inside the specifiedresourceImagePath,imageUrlrepresents fully qualified image URL.
NOTE: The path should end with a /:
new Calendar({
modeDefaults : {
showResourceAvatars : true,
resourceImagePath : 'images/resources/'
}
});
A button configuration object to use for the automatically created mode selector button for this mode.
A menu item configuration object to use for the automatically created mode selector menu item for this mode.
A DateHelper format string/function to use to create date output for abbreviated view descriptions.
| Parameter | Type | Description |
|---|---|---|
date | Date | The date to format. |
The formatted date.
A DateHelper format string/function to use to create date and time output for abbreviated view descriptions.
| Parameter | Type | Description |
|---|---|---|
date | Date | The date to format. |
The formatted date.
The class name to add to events which have duration less than or equal to shortEventDuration.
The duration at which below and equal to this value, an event's encapsulating element gets the shortEventCls added to it so that small event bars can have style rearrangements.
In DayViews, short events have compressed layout so that the event name is visible on the top line next to the start time.
This may be a string in the format required by parseDuration.
It may also be configured as a millisecond value.
Not applicable in a DayView
This specifies whether to show a circular "bullet" icon if there is no iconCls defined for an event.
By default, events which are rendered as solid blocks of colour (such as all day events) do not show the bullet icon.
By default, events which do not show as a colour block show the bullet icon as a means of showing
the event's defined eventColor.
This property may contain two properties which define whether to show the bullet icon for both event types.
If configured as true, all event bars will show a bullet icon if they do not have an
iconCls
| Parameter | Type | Description |
|---|---|---|
bar | Boolean | This is |
noBar | Boolean | This is |
Configure as true to show avatars of the assigned resources (calendars) at the
start of the event bar.
Configure as 'last' to show avatars of the assigned resources (calendars) at the
end of the event bar.
Note that the avatars are 2.22em diameter circles, and this may not be suitable
for rendering in short events inside a DayView.
In a view which renders event bars, the eventHeight should be increased from the default to accommodate the extra information.
Note that you must set resourceImagePath in order that the system knows where to access the resource's image file from.
If no image is set, or the image is not found, the resource's initials are shown instead.
By default it is inherited from the owning Calendar:
new Calendar({
resourceImagePath : 'images/resources/'
modes : {
month : {
showResourceAvatars : true,
},
week : {
// Images go at the end of the body with name first
showResourceAvatars : 'last,
}
}
});
The converse of syncViewDate
When a date, or an event is clicked in a calendar view, the Calendar's date is set to the clicked date to indicate that the user has expressed interest in that date.
This is for convenience, so that when switching modes, by default, the time span encapsulating the last date of interest is always shown.
To disable syncing the calendar's date with this view's date, configure this property as false.
This also prevents this view from being updated to the Calendar's date when this view becomes active.
When this is false, the only way views will navigate in time is when the user clicks the "Next" or "Previous"
buttons in the Calendar's toolbar, or when the user selects
a new date in the datePicker in the Calendar's toolbar.
The converse of syncCalendarDate
When used as a mode of a Calendar, this view's date will automatically be kept synced with the Calendar's date. So this view will move to encapsulate the Calendar's date.
Configure this as false to opt out of this.
Note that this places the onus on the application developer to control the viewed date range in this widget.
A DateHelper format string/function used to format the time displayed in events
| Parameter | Type | Description |
|---|---|---|
date | Date | The date to format. |
The formatted date.
A title text used by the Calendar's mode selector button. If not specified, the mode name is used.
The week start day, 0 meaning Sunday, 6 meaning Saturday. Defaults to weekStartDay.
Properties
39
Properties
39Class hierarchy
Other
Configure this as false to disable drag-creating events in this view.
Configure this as false to disable drag-moving events in this view.
Configure this as false to disable drag-resizing events in this view.
By default, when navigating through time, the next time block will be animated in from the appropriate direction.
Configure this as false to disable this.
{"gesture":"dblclick","newName":"L{Object.newEvent}","step":"15 minutes","snapType":"round","duration":"1 hour","startHour":8}Also a configIf this config is set, then the gesture configured (which defaults to dblclick) creates a
new event at the mouse or touch event's time point.
The exact time is rounded to the closest specified step value. This value is also used
for the step value in the EventEdit's
time input field.
The duration of the created event is the specified duration value.
If this is specified as true, the gesture becomes dblclick, and the other properties
are the default values listed below.
If this is specified as a string, the string becomes the gesture, and the other properties
are the default values listed below.
| Parameter | Type | Description |
|---|---|---|
gesture | String | The DOM event name which initiates event creation at the event's position. |
newName | function | String | The name of an event created using
|
step | String | The time unit by which to snap the start click point of auto created events.
Only for views which have a granularity of less than one day such as For views which show whole days, the start defaults to 8am. This is a string in the format required by parseDuration. This value is also used for the step value in the EventEdit's time input field. |
snapType | round | ceil | floor | How to snap a precise gesture time to a boundary specified by the |
duration | String | The default start hour for auto created events in the form accepted by parseDuration |
startHour | Number | The default start hour for auto created events
in views where the time granularity is one day. In a This is the hour of the day to start the event at. It may be fractional. |
The class name to add to calendar cells.
Options to add into scroll options when the scrollTo method is called.
By defult, scrolling is animated.
To make the scrolling animate with easing and highlight the target element, configure the view with
{
defaultScrollOptions : {
highlight : true,
animate : {
duration : 750,
easing : 'bounce'
}
}
}
The durationUnit to use when drag-creating events in this view.
For DayViews, this is normally 'hour', for views with a granularity
level of one day, the default is 'day'.
Configure this as null to have drag-create use the unit of the duration property of
the autoCreate config as the duration unit when drag-creating events.
The duration in total days that this view covers.
The number of visible events that this view currently displays in its date range.
Filtered out events are not incuded in the count.
Events from filtered out dates are not included in the count.
Events which are in hidden non-working days are not included in the count.
This value may be used when creating a view description string.
By default, the end date of an all day event is displayed in the UI as the last calendar date on which the event falls. For most end users, this is the expected value.
Technically, the endDate is a timestamp
which represents the exact point in time at which an event ends. To use this instead,
configure extendAllDayEndDay as true.
To be clear, this would mean that an allDay event starting and ending on the 7th of February 2020, would show the end date in the tooltip as 8th of February 2020.
The first visible event-bearing element in this view. So if the first day defined in the range is a Sunday, and hideNonWorkingDays is set, then the first visible cell will be for the Monday.
The date of the first visible event-bearing element in this view. So if the first day defined in the range is a Sunday, and hideNonWorkingDays is set, then the first visible date will be the date of the Monday.
Configure as true to hide nonWorkingDays
The last visible event-bearing element in this view. So if the last day defined in the range is a Sunday, and hideNonWorkingDays is set, then the last visible cell will be for the Friday.
The date of the last visible event-bearing element in this view. So if the last day defined in the range is a Sunday, and hideNonWorkingDays is set, then the last visible date will be the date of the Friday.
The maximum date to which the endDate of this view may be navigated.
The minimum date to which the startDate of this view may be navigated.
Calendar mode that this view represents (eg. "day", "month" etc). Only accessible when used within a Calendar.
Non-working days as an object where keys are day indices, 0-6 (Sunday-Saturday), and the value is true.
Defaults to nonWorkingDays.
The class name to add to events which have an end date in the past. Defaults to 'b-past-event'.
There are no CSS rules attached to this class. You may use it to style past events.
Configure as true to make the view read-only, by disabling any UIs for modifying data.
For example, the event editor will be set to read-only and will not allow changes to be made. And the EventMenu will not show options which can mutate the events.
Note that checks MUST always also be applied at the server side.
A DateHelper format string/function to use to create date output for abbreviated view descriptions.
| Parameter | Type | Description |
|---|---|---|
date | Date | The date to format. |
The formatted date.
A DateHelper format string/function to use to create date and time output for abbreviated view descriptions.
| Parameter | Type | Description |
|---|---|---|
date | Date | The date to format. |
The formatted date.
A String which describes how much the next and previous methods will move this view forwards or backwards in time.
This is used to create the tooltip hints for the nextButton and prevButton in the
Calendar's toolbar. If this property
is not defined, the nextButton and prevButton will be disabled when this view is active.
Note that WeekView and YearView use a localized
string property to yield this value. Other view types implement a get stepUnit getter because
their step increments are variable.
The converse of syncViewDate
When a date, or an event is clicked in a calendar view, the Calendar's date is set to the clicked date to indicate that the user has expressed interest in that date.
This is for convenience, so that when switching modes, by default, the time span encapsulating the last date of interest is always shown.
To disable syncing the calendar's date with this view's date, configure this property as false.
This also prevents this view from being updated to the Calendar's date when this view becomes active.
When this is false, the only way views will navigate in time is when the user clicks the "Next" or "Previous"
buttons in the Calendar's toolbar, or when the user selects
a new date in the datePicker in the Calendar's toolbar.
The converse of syncCalendarDate
When used as a mode of a Calendar, this view's date will automatically be kept synced with the Calendar's date. So this view will move to encapsulate the Calendar's date.
Configure this as false to opt out of this.
Note that this places the onus on the application developer to control the viewed date range in this widget.
This property yields the base selector to use to find visible cell elements in this view.
It's based upon the dayCellCls, but also takes into account the hideNonWorkingDays setting.
If this is a MonthView, it also takes into account the hideOtherMonthCells setting.
Functions
19
Functions
19Determines what is under the cursor of the specified event or what is described by the given element.
| Parameter | Type | Description |
|---|---|---|
domEvent | Event | Element | The event or element |
Creates an event on the specified date which conforms to this view's autoCreate setting.
This method may be called programmatically by application code if the autoCreate setting
is false, in which case the default values for autoCreate will be used.
If the EventEdit feature is active, the new event will be displayed in the event editor.
| Parameter | Type | Description |
|---|---|---|
date | Date | The date to add the event at. If there's no time component, the
autoCreate's |
Returns the cell associated with the passed date.
In certain views, the strict definition if whether the view owns the date may be optionally enforced.
For example, in a YearView or MonthView, dates outside the configured year or month may be displayed.
To exclude these, pass the strict parameter as true
| Parameter | Type | Description |
|---|---|---|
date | Date | String | The date to find the element for or a key in the format |
strict | Boolean | Only return the element if this view owns the date. (MonthView and YearView) |
Returns the outermost element which represents the first block of the passed event in the view. If the event is represented within the view.
Note if the event covers multiple weeks, this will only return the first element.
To return all elements use getEventElements.
To return an event element at a particular date, pass the date as the second parameter.
| Parameter | Type | Description |
|---|---|---|
eventRecord | EventModel | String | Number | The event, or event ID to find the element for. |
date | Date | Optionally, the event element at the specified date. |
The first element which corresponds to the event. Note that some views, such as MonthView and CalendarRow may render multiple elements for long events.
Returns all outermost elements which represents the passed event in the view. If the event is represented within the view
| Parameter | Type | Description |
|---|---|---|
eventRecord | EventModel | String | Number | The event, or event ID to find the elements for. |
The elements which corresponds to the event. Note that some views, such as MonthView and CalendarRow may render multiple elements for long events.
Returns the event record for a DOM element or DOM event.
| Parameter | Type | Description |
|---|---|---|
elementOrEvent | HTMLElement | Event | The DOM node to lookup, or a DOM event whose target to lookup. |
The event record
Returns the resource record for a DOM element or DOM event if the element is inside a view which displays events for one resource such as a ResourceView or a DayResourceView.
| Parameter | Type | Description |
|---|---|---|
elementOrEvent | HTMLElement | Event | The DOM node to lookup, or a DOM event whose target to lookup. |
The resource record
This is normally used by the TimeRanges feature to gather TimeRanges to render into the DayView or DayResourceView UI.
This returns an array of TimeRangeModels and/or ResourceTimeRangeModels to be rendered in the passed date range.
If this view has a resourceId, then by default only ResourceTimeRangeModels
for that resource are returned. If a resourceId is passed, then only ResourceTimeRangeModels
for that resource are returned unless you explicitly pass the last parameter (includeTimeRanges) as true.
If the includeTimeRanges is set on the owning view, then time ranges will always be included even though the view is a resource-based view.
This may be used by application code to check for time ranges in a certain date range for a view.
| Parameter | Type | Description |
|---|---|---|
startDate | Date | The start date of the range to be returned |
endDate | Date | The end date of the range to be returned. |
resourceId | String | Number | For use in a ResourceView or DayResourceView. |
includeTimeRanges | Boolean | For use in a ResourceView or DayResourceView.
Pass as |
The time ranges which fall within the passed date range. Each model has a coincidingEvents
property added to it which is an array of events which intersect the time range.
Returns true if the given date is today in the current time zone.
| Parameter | Type | Description |
|---|---|---|
date | Date | The date to check. |
true if the date is today, false otherwise.
Called when new event is created. Сan be overridden to supply default record values etc.
| Parameter | Type | Description |
|---|---|---|
eventRecord | EventModel | Newly created event |
Refreshes the UI after a change to the EventStore, or to a configuration that requires the UI to change.
Only updates the UI if this widget is visible. If it is not visible, the refresh is deferred until it next becomes visible.
Schedules a refresh of the UI for the next animation frame. This is a useful method to call when making multiple data changes, so that each change merely schedules a refresh for the next AF and DOM churn is kept to a minimum.
Calling refresh directly cancels any scheduled refresh operation and updates the UI immediately
Returns the event record for a DOM element or DOM event.
| Parameter | Type | Description |
|---|---|---|
elementOrEvent | HTMLElement | Event | The DOM node to lookup, or a DOM event whose target to lookup. |
The event record
Brings an event or a time into view. Optionally visually highlights the target.
This may change the date range encompassed by this view to bring the date or event into its ownership.
Scrolling may or may not be required, depending on the type and size constraints of the view.
Base scrolling options are added from the defaultScrollOptions config.
| Parameter | Type | Description |
|---|---|---|
target | EventModel | Date | The event or Date to scroll to. |
options | Object | How to scroll. |
options.block | start | end | center | nearest | How far to scroll the target. |
options.edgeOffset | Number | edgeOffset A margin around the target to bring into view. |
options.animate | Object | Boolean | Number | Set to |
options.animate.duration | Number | The number of milliseconds to animate over. |
options.animate.easing | String | The name of an easing function. |
options.highlight | Boolean | function | Set to |
options.focus | Boolean | Set to |
options.x | Boolean | Pass as |
options.y | Boolean | Pass as |
A promise which is resolved when the target has been scrolled into view.
Events
3
Events
3This event fires whenever the autoCreate gesture is detected and also when a drag-create gesture is detected.
This event is preventable and may be used to validate UI-initiated event creation.
// Adding a listener using the "on" method
calendarMixin.on('beforeAutoCreate', ({ domEvent, date, startDate, endDate, resourceRecord, view }) => {
});| Parameter | Type | Description |
|---|---|---|
domEvent | Event | The DOM event which initiated the creation. |
date | Date | DEPRECATED in favour of |
startDate | Date | The starting time of the event to be created. If this is in a
|
endDate | Date | The ending time of the event to be created. |
resourceRecord | ResourceModel | The resource if the UI includes a resource. |
view | CalendarView | This view. |
Triggered before a view's orientating date changes.
return false from an event handler to veto the temporal navigation.
// Adding a listener using the "on" method
calendarMixin.on('beforeChangeDate', ({ oldDate, date }) => {
});| Parameter | Type | Description |
|---|---|---|
oldDate | Date | The current orientating date of this view. |
date | Date | The new date to which this view is to be orientated. |
Fired when an autoCreate gesture has created a new event and added it to the event store.
If the EventEdit feature is present, it listens for
this event and initiates an edit operation. Adding a high prio listener which
returns false can prevent this event from reaching the eventEdit processing.
// Adding a listener using the "on" method
calendarMixin.on('eventAutoCreated', ({ source, eventRecord }) => {
});| Parameter | Type | Description |
|---|---|---|
source | CalendarView | This Calendar view instance. |
eventRecord | EventModel | The new event record. |
Event handlers
3
Event handlers
3This event called whenever the autoCreate gesture is detected and also when a drag-create gesture is detected.
This event is preventable and may be used to validate UI-initiated event creation.
new CalendarMixin({
onBeforeAutoCreate({ domEvent, date, startDate, endDate, resourceRecord, view }) {
}
});| Parameter | Type | Description |
|---|---|---|
domEvent | Event | The DOM event which initiated the creation. |
date | Date | DEPRECATED in favour of |
startDate | Date | The starting time of the event to be created. If this is in a
|
endDate | Date | The ending time of the event to be created. |
resourceRecord | ResourceModel | The resource if the UI includes a resource. |
view | CalendarView | This view. |
Called before a view's orientating date changes.
return false from an event handler to veto the temporal navigation.
new CalendarMixin({
onBeforeChangeDate({ oldDate, date }) {
}
});| Parameter | Type | Description |
|---|---|---|
oldDate | Date | The current orientating date of this view. |
date | Date | The new date to which this view is to be orientated. |
Called when an autoCreate gesture has created a new event and added it to the event store.
If the EventEdit feature is present, it listens for
this event and initiates an edit operation. Adding a high prio listener which
returns false can prevent this event from reaching the eventEdit processing.
new CalendarMixin({
onEventAutoCreated({ source, eventRecord }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | CalendarView | This Calendar view instance. |
eventRecord | EventModel | The new event record. |