Labels

Displays labels at positions top, right, bottom and left.

Labels
//<code-header>
fiddle.title = 'Labels';
//</code-header>
targetElement.innerHTML = '<p>Demo displaying top and bottom labels with top label; editable on <code>dblclick</code>:</p>';

const scheduler = new Scheduler({
    appendTo : targetElement,

    // makes scheduler as high as it needs to be to fit rows
    autoHeight : true,
    barMargin  : 5,
    rowHeight  : 70,

    features : {
        labels : {
            top : {
                field  : 'location',
                editor : {
                    type : 'textfield'
                }
            },
            bottom : {
                renderer : ({ eventRecord }) => `ID: ${eventRecord.id}`
            }
        }
    },

    startDate : new Date(2018, 4, 6),
    endDate   : new Date(2018, 4, 13),

    columns : [
        { field : 'name', text : 'Name', width : 100 }
    ],

    resources : [
        { id : 1, name : 'Bernard' },
        { id : 2, name : 'Bianca' }
    ],

    events : [
        { id : 1, resourceId : 1, name : 'Interview', location : 'Office', startDate : '2018-05-07', endDate : '2018-05-10' },
        { id : 2, resourceId : 2, name : 'Meeting', location : `Client's office`, startDate : '2018-05-10', endDate : '2018-05-12' }
    ]
});

Text in labels can be set from a field on the EventModel or the ResourceModel or using a custom renderer. See SchedulerLabelConfig for configuration specification.

new Scheduler({
   features : {
       labels : {
           // Label rendered above the event bar with content from the
           // record's location field
           top : {
               field  : 'location',
               editor : {
                   type : 'textfield'
               }
           },
           // Label rendered below the event bar with custom content
           // from a renderer
           bottom : {
               renderer : ({ eventRecord }) => `ID: ${eventRecord.id}`
           }
       }
   }
});

Since top and bottom labels occupy space that would otherwise be used by the event we recommend using bigger rowHeights (>55px for both labels with default styling) and zero barMargins because top/bottom labels give space around events anyway.

To prevent labels from being overlapped by other events, see labelLayoutMode.

This feature is disabled by default. It is not supported in vertical mode. For info on enabling it, see GridFeatures.

Configs

19

Common

disabledInstancePlugin
listenersEvents

Other

Configuration object for the label which appears after the event bar in the current writing direction.

Configuration object for the label which appears before the event bar in the current writing direction.

blurAction: complete | cancel= cancel

What action should be taken when focus moves leaves the cell editor, for example when clicking outside. May be 'complete' or 'cancel'.

Bottom label configuration object.

labelCharWidth: Number= 7

Factor representing the average char width in pixels used to determine label width when configured with labelLayoutMode: 'estimate'.

labelCls: String= b-sch-label

CSS class to apply to label elements

labelLayoutMode: default | estimate | measure= default

How to handle labels during event layout. Options are:

  • default - Labels do not affect event layout, events will overlap labels
  • estimate - Label width is estimated by multiplying text length with labelCharWidth
  • measure - Label width is determined by measuring the label, precise but slow

Note that this only applies to the left and right labels, top and bottom labels does not take part in the event layout process.

Left label configuration object.

Right label configuration object.

Top label configuration object.

Misc

clientInstancePlugin
localeClassLocalizable
localizableLocalizable

Properties

15

Common

disabledInstancePlugin

Class hierarchy

isLabels: Boolean= truereadonly
Identifies an object as an instance of Labels class, or subclass thereof.
isLabels: Boolean= truereadonlystatic
Identifies an object as an instance of Labels class, or subclass thereof.
isEventsEvents
isInstancePluginInstancePlugin
isLocalizableLocalizable

Lifecycle

configBase

Misc

clientInstancePlugin
localeHelperLocalizable
localeManagerLocalizable

Other

Functions

28

Configuration

applyDefaultsstaticBase

Events

Lifecycle

destroystaticBase

Misc

doDisableInstancePlugin
initClassstaticBase
isOfTypeNamestaticBase
mixinstaticBase
optionalLstaticLocalizable

Other

LstaticLocalizable
onEvents
relayAllEvents
triggerEvents
unEvents

Events

5
catchAllEvents
destroyEvents
disableInstancePlugin
enableInstancePlugin

Event handlers

5
onDestroyEvents
onDisableInstancePlugin
onEnableInstancePlugin

Typedefs

2

Configuration object for a label used by the Labels feature.

ParameterTypeDescription
fieldString

The name of a field in one of the associated records, EventModel or ResourceModel. The record from which the field value is drawn will be ascertained by checking for field definitions by the specified name.

rendererfunction

A function, which when passed an object containing eventRecord, resourceRecord, assignmentRecord and domConfig properties, returns the HTML to display as the label.

renderer.eventRecordEventModel
renderer.resourceRecordResourceModel
renderer.assignmentRecordAssignmentModel
renderer.domConfigDomConfig

The DomConfig object representing the label element

thisObjObject

The this reference to use in the renderer.

editorInputFieldConfig | Field

If the label is to be editable, a field configuration object with a type property, or an instantiated Field. The field property is mandatory for editing to work.

CSS variables

6
NameDescription
--b-event-label-font-sizeLabel font size
--b-event-label-font-weightLabel font weight
--b-event-label-gapGap between label and event bar
--b-event-label-colorLabel color
--b-event-label-backgroundLabel background
Selected
--b-selected-event-label-colorLabel color when event is selected