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.
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
- ResourceTimeRangeModel - Resource time range data model
- ResourceTimeRangeStore - Resource time range store
- TimeRanges - Time ranges (not resource-specific)
Configs
Configs are options you supply in a configuration object when creating an instance of this class-
Set to
trueto 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
Properties
Properties are getters/setters or publicly accessible variables on this class-
Identifies an object as an instance of ResourceTimeRanges class, or subclass thereof.
-
Set to
trueto 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.
-
Identifies an object as an instance of ResourceTimeRanges class, or subclass thereof.