SchedulerEventRendering

Configs

21

Milestones

milestoneAlign: start | center | end= centerAlso a property

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'.

milestoneLayoutMode: default | estimate | data | measure= defaultAlso a property

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.
milestoneTextPosition: inside | outside | always-outside= outsideAlso a property

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.

ParameterTypeDescription
aEventModel

First event

bEventModel

Second event

Returns: Number -

Return -1 to display a above b, 1 for b above a

useInitialAnimation: Boolean | fade-in | slide-from-left | slide-from-top | String= trueAlso a property

By 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.

When combined with barMargin, events can still shrink below the limit. Adjust the value to suite your needs

new Scheduler({
  eventLayout : 'pack',
  minPackSize : 10
});

This setting is currently only used in horizontal mode.

Being experimental, this API might be removed or adjusted with short notice in the future.

resourceImagesSchedulerResourceRendering

Scheduled events

barMargin: Number

Controls how much space to leave between stacked event bars in px.

Can be configured per resource by setting resource.barMargin.

eventBarTextField: String= name

Field from EventModel displayed as text in the bar when rendering

eventLayout: stack | pack | mixed | none | ObjectAlso a property

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 events
  • mixed, 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' }
})
ParameterTypeDescription
eventLayout.typestack | pack | mixed | none
eventRenderer: function

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.

You should never modify any records inside this method.

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.

When returning content, be sure to consider how that content should be encoded to avoid XSS (Cross-Site Scripting) attacks. This is especially important when including user-controlled data such as the event's 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}`;
 }
ParameterTypeDescription
detailObject

An object containing the information needed to render an Event.

detail.eventRecordEventModel

The event record.

detail.resourceRecordResourceModel

The resource record.

detail.assignmentRecordAssignmentModel

The assignment record.

detail.schedulerScheduler

The Scheduler instance.

detail.renderDataObject

An object containing details about the event rendering.

detail.renderData.eventEventModel

The event record.

detail.renderData.clsDomClassList | 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.wrapperClsDomClassList | 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.iconClsDomClassList | 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 renderData.iconCls = null.

detail.renderData.leftNumber

Vertical offset position (in pixels) on the time axis.

detail.renderData.widthNumber

Width in pixels of the event element.

detail.renderData.heightNumber

Height in pixels of the event element.

detail.renderData.styleString | Object<String, String>

Inline styles for the event bar DOM element. Use either 'border: 1px solid black' or { border: '1px solid black' }

detail.renderData.wrapperStyleString | Object<String, String>

Inline styles for wrapper of the event bar DOM element. Use either 'border: 1px solid green' or { border: '1px solid green' }

detail.renderData.eventStyletonal | filled | bordered | traced | outlined | indented | line | dashed | minimal | rounded | calendar | interday | gantt | null

The eventStyle of the event. Use this to apply custom styles to the event DOM element

detail.renderData.eventColorString

The eventColor of the event. Use this to set a custom color for the rendered event

detail.renderData.ariaLabelString

A description of the event details used for screen readers

detail.renderData.childrenDomConfig[]

An array of DOM configs used as children to the b-sch-event element. Can be populated with additional DOM configs to have more control over contents.

Returns: String | DomConfig | DomConfig[] -

A simple string, or a DomConfig (or array thereof)

this reference for the eventRenderer function

narrowEventWidth: Number= 10

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.

resourceMarginSchedulerResourceRendering

Resources

defaultResourceImageNameSchedulerResourceRendering
resourceColumnsSchedulerResourceRendering
resourceImageExtensionSchedulerResourceRendering
resourceImagePathSchedulerResourceRendering

Properties

16

Class hierarchy

isSchedulerEventRendering: Boolean= truereadonly
Identifies an object as an instance of SchedulerEventRendering class, or subclass thereof.
isSchedulerEventRendering: Boolean= truereadonlystatic
Identifies an object as an instance of SchedulerEventRendering class, or subclass thereof.
isSchedulerResourceRenderingSchedulerResourceRendering

Milestones

milestoneAlign: start | center | end= centerAlso a config

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'.

milestoneLayoutMode: default | estimate | data | measure= defaultAlso a config

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.
milestoneTextPosition: inside | outside | always-outside= outsideAlso a config

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.

ParameterTypeDescription
aEventModel

First event

bEventModel

Second event

Returns: Number -

Return -1 to display a above b, 1 for b above a

useInitialAnimation: Boolean | fade-in | slide-from-left | slide-from-top | String= trueAlso a config

By 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.

When combined with barMargin, events can still shrink below the limit. Adjust the value to suite your needs

new Scheduler({
  eventLayout : 'pack',
  minPackSize : 10
});

This setting is currently only used in horizontal mode.

Being experimental, this API might be removed or adjusted with short notice in the future.

resourceColumnsSchedulerResourceRendering
resourceColumnWidthSchedulerResourceRendering

Scheduled events

eventLayout: stack | pack | mixed | none | ObjectAlso a config

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 events
  • mixed, 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' }
})
ParameterTypeDescription
eventLayout.typestack | pack | mixed | none
resourceMarginSchedulerResourceRendering

Functions

3

Milestones

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.

ParameterTypeDescription
eventRecordEventModel
resourceRecordResourceModel
Returns: Number

Misc

Restarts initial events animation with new value useInitialAnimation.

ParameterTypeDescription
initialAnimationBoolean | String

new initial animation value

Rendering

Rerenders events for specified resource (by rerendering the entire row).

ParameterTypeDescription
resourceRecordResourceModel

Typedefs

1

Layout data object used to lay out an event record.

ParameterTypeDescription
eventRecordEventModel

Event instance

resourceRecordResourceModel

Assigned resource

assignmentRecordAssignmentModel

Assignment instance

startMSNumber

Event start date time in milliseconds

endMSNumber

Event end date in milliseconds

heightNumber

Calculated event element height

widthNumber

Calculated event element width

topNumber

Calculated event element top position in the row (or column)

leftNumber

Calculated event element left position in the row (or column)

CSS variables

23
NameDescription
--b-sch-event-font-weightEvent font weight (overridden by event styles)
--b-sch-event-padding-inlineEvent padding inline
--b-sch-event-padding-blockEvent padding block
--b-sch-event-transitionEvent transitions that are always enabled (for hover effects)
--b-sch-event-animating-transitionEvent transitions that are enabled when Scheduler is animating
--b-sch-event-cursorEvent cursor
--b-sch-event-opacityEvent opacity (overridden by event styles)
--b-sch-event-border-widthEvent border-width. Must include a unit even when 0, for calculations to be correct (overridden by event styles)
--b-sch-event-width-reductionEvent width reduction, to leave a small gap between events that end / start at the same time
--b-sch-event-min-sizeEvents min-width (height in vertical mode), to ensure even very short events are visible
--b-sch-event-content-widthEvent content width (when not using sticky events)
--b-sch-event-content-heightEvent content height (when not using sticky events)
--b-sch-event-border-radiusEvent border radius (overridden by event styles)
--b-sch-event-border-styleEvent border style (overridden by event styles)
--b-sch-event-box-shadowEvent box-shadow (overridden by event styles)
--b-sch-event-font-sizeEvent font size (overridden by event styles)
--b-sch-milestone-gapGap between milestone diamond and its label
--b-sch-milestone-border-widthMilestone border width (overridden by event styles)
--b-sch-event-backgroundEvent background color (overridden by event styles)
--b-sch-event-border-colorEvent border color (overridden by event styles)
--b-sch-event-colorEvent text color (overridden by event styles)
Hovered
--b-sch-event-hover-backgroundHovered event's background color (overridden by event styles)
Selected
--b-sch-event-selected-backgroundSelected event's background color (overridden by event styles)