SchedulerEventRendering
Configs
21
Configs
21Milestones
How to align milestones in relation to their startDate. Only applies when using a milestoneLayoutMode
other than default. Valid values are:
- start
- center (default)
- end
Factor representing the average char width in pixels used to determine milestone width when configured
with milestoneLayoutMode: 'estimate'.
How to handle milestones during event layout. How the milestones are displayed when part of the layout are controlled using milestoneTextPosition.
Options are:
- default - Milestones do not affect event layout
- estimate - Milestone width is estimated by multiplying text length with Scheduler#milestoneCharWidth
- data - Milestone width is determined by checking EventModel#milestoneWidth
- measure - Milestone width is determined by measuring label width Please note that currently text width is always determined using EventModel#name. Also note that only 'default' is supported by eventStyles line, dashed and minimal.
Position of the milestone text:
- 'inside' - for short 1-char text displayed inside the diamond, not applicable when using milestoneLayoutMode)
- 'outside' - for longer text displayed outside the diamond, but inside it when using milestoneLayoutMode
- 'always-outside' - outside even when combined with milestoneLayoutMode
Misc
Maximum duration (in milliseconds) for the initial animation controlled by useInitialAnimation.
Override this method to provide a custom sort function to sort any overlapping events. This only applies to the horizontal mode, where the order the events are sorted in determines their vertical placement within a resource.
By default, overlapping events are laid out based on the start date. If the start date is equal, events with earlier end date go first. And lastly the name of events is taken into account.
Here's a sample sort function, sorting on start- and end date. If this function returns -1, then event
a is placed above event b:
overlappingEventSorter(a, b) {
const startA = a.startDate, endA = a.endDate;
const startB = b.startDate, endB = b.endDate;
const sameStart = (startA - startB === 0);
if (sameStart) {
return endA > endB ? -1 : 1;
} else {
return (startA < startB) ? -1 : 1;
}
}
NOTE: The algorithms (stack, pack) that lay the events out expects them to be served in chronological
order, be sure to first sort by startDate to get predictable results.
| Parameter | Type | Description |
|---|---|---|
a | EventModel | First event |
b | EventModel | Second event |
Return -1 to display a above b, 1 for b above a
trueAlso a propertyBy default, scheduler fade events in on load. Specify false to prevent this animation or specify one
of the available animation types to use it (true equals 'fade-in'):
- fade-in (default)
- slide-from-left
- slide-from-top
// Slide events in from the left on load
scheduler = new Scheduler({
useInitialAnimation : 'slide-from-left'
});
Other
An advanced setting that controls the maximum number of released event bars to keep in the DOM.
Schedulers virtualization releases event bars that go out of view, which means they are hidden but not removed from the DOM. When another event bar enters view, a released one is reused. This is faster than removing and re-adding the event bars from the DOM.
By default, all released event bars are kept around, and you should in general not need to adjust this setting. But if you have an app in which the scheduler sometimes displays a very large number of events on the screen at the same time, and sometimes only a few, you can experiment with tweaking this setting to free up some memory in the sparse case.
Experimental Minimum size that events should be allowed to shrink to when using pack layout. If
packing leads to any event being smaller than this value, the row will grow in height instead to maintain
this minimum size.
barMargin, events can still shrink below the limit. Adjust the value to suite
your needsnew Scheduler({
eventLayout : 'pack',
minPackSize : 10
});
Scheduled events
Controls how much space to leave between stacked event bars in px.
Can be configured per resource by setting resource.barMargin.
Field from EventModel displayed as text in the bar when rendering
Defines how to handle overlapping events. Valid values are:
stack, adjusts row height (only horizontal)pack, adjusts event height in horizontal mode, (width in vertical mode) to fit all eventsmixed, allows two events to overlap, more packs (only vertical)none, allows events to overlap
In horizontal mode, the default value is stack, in vertical mode it is pack.
This config can also accept an object:
new Scheduler({
eventLayout : { type : 'stack' }
})
| Parameter | Type | Description |
|---|---|---|
eventLayout.type | stack | pack | mixed | none |
An empty function by default, but provided so that you can override it. This function is called each time
an event is rendered into the schedule to render the contents of the event. It's called with the event,
its resource and a renderData object which allows you to populate data placeholders inside the event
template.
By default, the DOM markup of an event bar includes placeholders for 'cls' and 'style'. The cls property is a DomClassList which will be added to the event element. The style property is an inline style declaration for the event element.
name. The function encodeHtml as well as
xss can be helpful in these cases.
eventRenderer({ eventRecord, resourceRecord, renderData }) {
renderData.style = 'color:white'; // You can use inline styles too.
// Property names with truthy values are added to the resulting elements CSS class.
renderData.cls.isImportant = this.isImportant(eventRecord);
renderData.cls.isModified = eventRecord.isModified;
// Remove a class name by setting the property to false
renderData.cls[scheduler.generatedIdCls] = false;
// Or, you can treat it as a string, but this is less efficient, especially
// if your renderer wants to *remove* classes that may be there.
renderData.cls += ' extra-class';
return StringHelper.xss`${DateHelper.format(eventRecord.startDate, 'YYYY-MM-DD')}: ${eventRecord.name}`;
}
| Parameter | Type | Description |
|---|---|---|
detail | Object | An object containing the information needed to render an Event. |
detail.eventRecord | EventModel | The event record. |
detail.resourceRecord | ResourceModel | The resource record. |
detail.assignmentRecord | AssignmentModel | The assignment record. |
detail.scheduler | Scheduler | The Scheduler instance. |
detail.renderData | Object | An object containing details about the event rendering. |
detail.renderData.event | EventModel | The event record. |
detail.renderData.cls | DomClassList | String | An object whose property names represent the CSS class names to be added to the event bar element. Set a property's value to truthy or falsy to add or remove the class name based on the property name. Using this technique, you do not have to know whether the class is already there, or deal with concatenation. |
detail.renderData.wrapperCls | DomClassList | String | An object whose property names represent the CSS class names to be added to the event wrapper element. Set a property's value to truthy or falsy to add or remove the class name based on the property name. Using this technique, you do not have to know whether the class is already there, or deal with concatenation. |
detail.renderData.iconCls | DomClassList | String | An object whose property names represent the CSS class names to be added to an event icon element. Note that an element carrying this icon class is injected into the event element after the renderer completes, before the renderer's created content. To disable this if the renderer takes full control and creates content using the iconCls,
you can set |
detail.renderData.left | Number | Vertical offset position (in pixels) on the time axis. |
detail.renderData.width | Number | Width in pixels of the event element. |
detail.renderData.height | Number | Height in pixels of the event element. |
detail.renderData.style | String | Object<String, String> | Inline styles for the event bar DOM element.
Use either 'border: 1px solid black' or |
detail.renderData.wrapperStyle | String | Object<String, String> | Inline styles for wrapper of the
event bar DOM element. Use either 'border: 1px solid green' or |
detail.renderData.eventStyle | tonal | filled | bordered | traced | outlined | indented | line | dashed | minimal | rounded | calendar | interday | gantt | null | The |
detail.renderData.eventColor | String | The |
detail.renderData.ariaLabel | String | A description of the event details used for screen readers |
detail.renderData.children | DomConfig[] | An array of DOM configs used as children to the
|
this reference for the eventRenderer function
When an event bar has a width less than this value, it gets the CSS class b-sch-event-narrow
added. You may apply custom CSS rules using this class.
In vertical mode, this class causes the text to be rotated so that it runs vertically.
Resources
Properties
16
Properties
16Class hierarchy
Milestones
How to align milestones in relation to their startDate. Only applies when using a milestoneLayoutMode
other than default. Valid values are:
- start
- center (default)
- end
Factor representing the average char width in pixels used to determine milestone width when configured
with milestoneLayoutMode: 'estimate'.
How to handle milestones during event layout. How the milestones are displayed when part of the layout are controlled using milestoneTextPosition.
Options are:
- default - Milestones do not affect event layout
- estimate - Milestone width is estimated by multiplying text length with Scheduler#milestoneCharWidth
- data - Milestone width is determined by checking EventModel#milestoneWidth
- measure - Milestone width is determined by measuring label width Please note that currently text width is always determined using EventModel#name. Also note that only 'default' is supported by eventStyles line, dashed and minimal.
Position of the milestone text:
- 'inside' - for short 1-char text displayed inside the diamond, not applicable when using milestoneLayoutMode)
- 'outside' - for longer text displayed outside the diamond, but inside it when using milestoneLayoutMode
- 'always-outside' - outside even when combined with milestoneLayoutMode
Misc
Maximum duration (in milliseconds) for the initial animation controlled by useInitialAnimation.
Override this method to provide a custom sort function to sort any overlapping events. See overlappingEventSorter for more details.
| Parameter | Type | Description |
|---|---|---|
a | EventModel | First event |
b | EventModel | Second event |
Return -1 to display a above b, 1 for b above a
trueAlso a configBy default, scheduler fade events in on load. Specify false to prevent this animation or specify one
of the available animation types to use it (true equals 'fade-in'):
- fade-in (default)
- slide-from-left
- slide-from-top
// Slide events in from the left on load
scheduler = new Scheduler({
useInitialAnimation : 'slide-from-left'
});
Other
An advanced setting that controls the maximum number of released event bars to keep in the DOM.
Schedulers virtualization releases event bars that go out of view, which means they are hidden but not removed from the DOM. When another event bar enters view, a released one is reused. This is faster than removing and re-adding the event bars from the DOM.
By default, all released event bars are kept around, and you should in general not need to adjust this setting. But if you have an app in which the scheduler sometimes displays a very large number of events on the screen at the same time, and sometimes only a few, you can experiment with tweaking this setting to free up some memory in the sparse case.
Experimental Minimum size that events should be allowed to shrink to when using pack layout. If
packing leads to any event being smaller than this value, the row will grow in height instead to maintain
this minimum size.
barMargin, events can still shrink below the limit. Adjust the value to suite
your needsnew Scheduler({
eventLayout : 'pack',
minPackSize : 10
});
Scheduled events
Defines how to handle overlapping events. Valid values are:
stack, adjusts row height (only horizontal)pack, adjusts event height in horizontal mode, (width in vertical mode) to fit all eventsmixed, allows two events to overlap, more packs (only vertical)none, allows events to overlap
In horizontal mode, the default value is stack, in vertical mode it is pack.
This config can also accept an object:
new Scheduler({
eventLayout : { type : 'stack' }
})
| Parameter | Type | Description |
|---|---|---|
eventLayout.type | stack | pack | mixed | none |
Functions
3
Functions
3Milestones
Determines width of a milestones label. How width is determined is decided by configuring milestoneLayoutMode. Please note that text width is always determined using the events name.
| Parameter | Type | Description |
|---|---|---|
eventRecord | EventModel | |
resourceRecord | ResourceModel |
Misc
Restarts initial events animation with new value useInitialAnimation.
| Parameter | Type | Description |
|---|---|---|
initialAnimation | Boolean | String | new initial animation value |
Rendering
Rerenders events for specified resource (by rerendering the entire row).
| Parameter | Type | Description |
|---|---|---|
resourceRecord | ResourceModel |
Typedefs
1
Typedefs
1Layout data object used to lay out an event record.
| Parameter | Type | Description |
|---|---|---|
eventRecord | EventModel | Event instance |
resourceRecord | ResourceModel | Assigned resource |
assignmentRecord | AssignmentModel | Assignment instance |
startMS | Number | Event start date time in milliseconds |
endMS | Number | Event end date in milliseconds |
height | Number | Calculated event element height |
width | Number | Calculated event element width |
top | Number | Calculated event element top position in the row (or column) |
left | Number | Calculated event element left position in the row (or column) |
CSS variables
23
CSS variables
23| Name | Description |
|---|---|
--b-sch-event-font-weight | Event font weight (overridden by event styles) |
--b-sch-event-padding-inline | Event padding inline |
--b-sch-event-padding-block | Event padding block |
--b-sch-event-transition | Event transitions that are always enabled (for hover effects) |
--b-sch-event-animating-transition | Event transitions that are enabled when Scheduler is animating |
--b-sch-event-cursor | Event cursor |
--b-sch-event-opacity | Event opacity (overridden by event styles) |
--b-sch-event-border-width | Event border-width. Must include a unit even when 0, for calculations to be correct (overridden by event styles) |
--b-sch-event-width-reduction | Event width reduction, to leave a small gap between events that end / start at the same time |
--b-sch-event-min-size | Events min-width (height in vertical mode), to ensure even very short events are visible |
--b-sch-event-content-width | Event content width (when not using sticky events) |
--b-sch-event-content-height | Event content height (when not using sticky events) |
--b-sch-event-border-radius | Event border radius (overridden by event styles) |
--b-sch-event-border-style | Event border style (overridden by event styles) |
--b-sch-event-box-shadow | Event box-shadow (overridden by event styles) |
--b-sch-event-font-size | Event font size (overridden by event styles) |
--b-sch-milestone-gap | Gap between milestone diamond and its label |
--b-sch-milestone-border-width | Milestone border width (overridden by event styles) |
--b-sch-event-background | Event background color (overridden by event styles) |
--b-sch-event-border-color | Event border color (overridden by event styles) |
--b-sch-event-color | Event text color (overridden by event styles) |
| Hovered | |
--b-sch-event-hover-background | Hovered event's background color (overridden by event styles) |
| Selected | |
--b-sch-event-selected-background | Selected event's background color (overridden by event styles) |