v7.3.0
SupportExamplesFree Trial

ResourceTimeRanges
Feature

Feature that draws resource time ranges, shaded areas displayed behind events. These zones are similar to events in that they have a start and end date but different in that they do not take part in the event layout, and they always occupy full row height.

targetElement.innerHTML = '<p>This demo shows the built-in colors available for resource time ranges:</p>'; const scheduler = new Scheduler({ appendTo : targetElement, // makes scheduler as high as it needs to be to fit rows autoHeight : true, features : { resourceTimeRanges : true }, startDate : new Date(2018, 10, 25), endDate : new Date(2018, 11, 8), rowHeight : 100, barMargin : 20, eventStyle : 'filled', columns : [ { field : 'name', text : 'Name', width : 100 } ], resources : [ { id : 1, name : 'Lady' }, { id : 2, name : 'Dude' } ], events : [ { id : 1, resourceId : 1, name : 'Event 1', startDate : '2018-11-29', duration : 2 }, { id : 2, resourceId : 2, name : 'Event 2', startDate : '2018-11-30', duration : 2 } ], resourceTimeRanges : [ { id : 1, resourceId : 1, name : 'Custom HTML', timeRangeColor : 'red', startDate : '2018-11-25', duration : 2 }, { id : 2, resourceId : 2, name : 'Pink', timeRangeColor : 'pink', startDate : '2018-11-25', duration : 2 }, { id : 3, resourceId : 1, name : 'Purple', timeRangeColor : 'purple', startDate : '2018-11-27', duration : 2 }, { id : 4, resourceId : 2, name : 'Violet', timeRangeColor : 'violet', startDate : '2018-11-27', duration : 2 }, { id : 5, resourceId : 1, name : 'Indigo', timeRangeColor : 'indigo', startDate : '2018-11-29', duration : 2 }, { id : 6, resourceId : 2, name : 'Blue', timeRangeColor : 'blue', startDate : '2018-11-29', duration : 2 }, { id : 7, resourceId : 1, name : 'Cyan', timeRangeColor : 'cyan', startDate : '2018-12-01', duration : 2 }, { id : 8, resourceId : 2, name : 'Teal', timeRangeColor : 'teal', startDate : '2018-12-01', duration : 2 }, { id : 9, resourceId : 1, name : 'Green', timeRangeColor : 'green', startDate : '2018-12-03', duration : 2 }, { id : 11, resourceId : 2, name : 'Lime', timeRangeColor : 'lime', startDate : '2018-12-03', duration : 2 }, { id : 12, resourceId : 1, name : 'Yellow (default)', startDate : '2018-12-05', duration : 2 }, { id : 13, resourceId : 2, name : 'Orange', timeRangeColor : 'orange', startDate : '2018-12-05', duration : 2 } ], resourceTimeRangeRenderer({ resourceTimeRangeRecord, resourceRecord, renderData }) { if (resourceTimeRangeRecord.id === 1) { // Adds a CSS class to the range element renderData.cls.important = 1; return [ { tag : 'i', class : 'fa fa-warning', style : 'margin-inline-end:.5em' }, { tag : 'strong', text : `${DateHelper.format(resourceTimeRangeRecord.startDate, 'MMM DD')} ${resourceTimeRangeRecord.name}` } ]; } return resourceTimeRangeRecord.name; } });

Each time range is represented by an instances of ResourceTimeRangeModel, held in a ResourceTimeRangeStore. Currently they are readonly UI-wise, but can be manipulated on the data level. To style the rendered elements, use the cls field or use the timeRangeColor field.

Data can be provided either using the resourceTimeRanges config on the Scheduler config object:

new Scheduler({
    ...
   features :  {
       resourceTimeRanges : true
   },

// Data specified directly on the Scheduler instance resourceTimeRanges : [ // Either specify startDate & endDate or startDate & duration when defining a range { startDate : new Date(2019,0,1), endDate : new Date(2019,0,3), name : 'Occupied', timeRangeColor : 'red' }, { startDate : new Date(2019,0,3), duration : 2, durationUnit : 'd', name : 'Available' }, ] })

Or the resourceTimeRangeStore config on the Scheduler config object:

new Scheduler({
    ...
    features :  {
        resourceTimeRanges : true
    },
    resourceTimeRangeStore : new ResourceTimeRangeStore({
        readUrl : './resourceTimeRanges/'
    })
})

Or on the project, using the resourceTimeRangesData config.

This feature is disabled by default. For info on enabling it, see GridFeatures.

Recurring ranges support

Resource time ranges can also be recurring, as seen in the example below:

const resourceTimeRangeStore = new ResourceTimeRangeStore({
    data : [{
        id             : 1,
        resourceId     : 'r1',
        startDate      : '2019-01-01T11:00',
        endDate        : '2019-01-01T13:00',
        name           : 'Lunch',
        // this time range will repeat every day
        recurrenceRule : 'FREQ=DAILY'
    }]
});

Rendering custom HTML markup

Sometimes it is handy to be able to output custom HTML into the range elements. This can be done using the resourceTimeRangeRenderer config method.

// You can use a custom renderer method to output the contents of the range elements. The return value should
// be a string or a DOMConfig object defining the markup to generate
new Scheduler({
    resourceTimeRangeRenderer{ resourceTimeRangeRecord, resourceRecord, renderData }) {
        if (resourceTimeRangeRecord.important) {
            // Add a CSS class to the range element
            renderData.cls.important = 1;

return [ { tag : 'i', class : 'fa fa-warning' }, { tag : 'strong', text : resourceTimeRangeRecord.name } ]; } return resourceTimeRangeRecord.name; } })

Useful configs and functions

Member Description
resourceTimeRangeRenderer Custom renderer function for time ranges
resolveResourceTimeRangeRecord Resolve a record from a DOM element
resourceTimeRangeClick Fires on time range click
resourceTimeRangeDblClick Fires on time range double-click
resourceTimeRangeContextMenu Fires on time range right-click

See also

No results

Configs

Configs are options you supply in a configuration object when creating an instance of this class
  • Set to true to allow mouse interactions with the rendered range elements. By default, the range elements are not reachable with the mouse, and only serve as a static background.

    Has a corresponding runtime enableMouseEvents property.

  • Specify value to use for the tabIndex attribute of resource time range elements

  • Internal listeners, that cannot be removed by the user.

  • The widget which this plugin is to attach to.

    Has a corresponding runtime client property.

  • Set to false to disable localization of this object.

Properties

Properties are getters/setters or publicly accessible variables on this class
  • isEvents : Booleantrue
    READONLY
    static
    ADVANCED
    Events
    Identifies an object as an instance of Events class, or subclass thereof.
  • isLocalizable : Booleantrue
    READONLY
    static
    ADVANCED
    Localizable
    Identifies an object as an instance of Localizable class, or subclass thereof.
  • isResourceTimeRanges : Booleantrue
    READONLY
    static
    ADVANCED
    Identifies an object as an instance of ResourceTimeRanges class, or subclass thereof.
  • A class property getter for the default values of internal properties for this class.

  • Set to true to allow mouse interactions with the rendered range elements. By default, the range elements are not reachable with the mouse, and only serve as a static background.

    Has a corresponding enableMouseEvents config.

  • An empty array that can be used as a default value.

  • An empty object that can be used as a default value.

  • Identifies an object as an instance of InstancePlugin class, or subclass thereof.
  • isResourceTimeRanges : Booleantrue
    READONLY
    ADVANCED
    Identifies an object as an instance of ResourceTimeRanges class, or subclass thereof.
  • Identifies an object as an instance of ResourceTimeRangesBase class, or subclass thereof.
  • Returns a copy of the full configuration which was used to configure this object.

  • This property is set to true before the constructor returns.

  • This property is set to true on entry to the destroy method. It remains on the objects after returning from destroy(). If isDestroyed is true, this property will also be true, so there is no need to test for both (for example, comp.isDestroying || comp.isDestroyed).

  • The Widget which was passed into the constructor, which is the Widget we are providing extra services for.

    Has a corresponding client config.

  • Get the global LocaleHelper

  • Get the global LocaleManager

Functions

Functions are methods available for calling on the class
  • This optional class method is called when a class is mixed in using the mixin() method.

  • Registers this class type with its Factory

  • Internal function used to hook destroy() calls when using thisObj

  • Internal function used restore hooked destroy() calls when using thisObj

  • doDestroy( )
    internal
    Events

    Auto detaches listeners registered from start, if set as detachable

  • once( )
    private
    Events

    Internal function used to run a callback function after an event is triggered

  • Removes all listeners registered to this object by the application.

  • This will merge a feature's (subclass of InstancePlugin) keyMap with it's client's keyMap.

Events

Events are triggered for certain actions in this class and can be listened for to react to those actions in your code

Event handlers

Event handlers are callbacks called as a result of certain actions in this class
id: resourceTimeRanges

Source path

Scheduler/feature/ResourceTimeRanges.js

Demo

examples/resourcetimeranges

Contents