TimeSelection
Feature
Feature that allows selection of a time span in the time axis header. When a time span is selected in the header, a timeSelectionChange event is fired.
const scheduler = new Scheduler({ appendTo : targetElement, // makes scheduler as high as it needs to be to fit rows autoHeight : true, features : { timeSelection : { headerRenderer({ timeRange }) { return `<span>${DateHelper.format(timeRange.startDate, 'LST')}</span> <span>${DateHelper.format(timeRange.endDate, 'LST')}</span> <i class='fa fa-close' data-btip="Close"></i>`; } } }, viewPreset : 'hourAndDay', startDate : new Date(2022, 4, 8, 8), endDate : new Date(2022, 4, 8, 16), columns : [ { field : 'name', text : 'Name', width : 100 } ], resources : [ { id : 1, name : 'Bernard' }, { id : 2, name : 'Bianca' }, { id : 3, name : 'Rolf' }, { id : 4, name : 'Bengt' }, { id : 5, name : 'Penny' } ], events : [ { id : 1, resourceId : 1, name : 'Interview', startDate : '2022-05-08T09:00:00', endDate : '2022-05-08T10:00:00' }, { id : 2, resourceId : 2, name : 'Meeting', startDate : '2022-05-08T13:00:00', endDate : '2022-05-08T15:00:00' }, { id : 3, resourceId : 3, name : 'Future task', startDate : '2022-05-08T09:00:00', endDate : '2022-05-08T11:30:00' } ], bbar : [ { ref : 'selectionLabel', type : 'widget' } ], getAvailableResources(startDate, endDate) { return this.resourceStore.query(resource => this.isDateRangeAvailable(startDate, endDate, null, resource)); }, onTimeSelectionChange({ startDate, endDate }) { const availableResources = startDate ? this.getAvailableResources(startDate, endDate).length : this.resourceStore.count; this.widgetMap.selectionLabel.html = `${availableResources} resources available`; } }); scheduler.features.timeSelection.selectedTimeSpan = { startDate : new Date(2022, 4, 8, 10), endDate : new Date(2022, 4, 8, 13) }; Configuration
You can configure the content of the header element using the headerRenderer function.
This feature is disabled by default. For info on enabling it, see GridFeatures.
Useful configs and functions
| Member | Description |
|---|---|
| tooltipTemplate | Template for the selection tooltip |
| headerRenderer | Custom renderer for the header highlight |
| selectedTimeSpan | Currently selected time span |
| timeSelectionChange | Fires when time selection changes |
See also
- HeaderZoom - Header drag-to-zoom
- AbstractTimeRanges - Base time ranges feature
- ScheduleContext - Schedule cell selection
Configs
Configs are options you supply in a configuration object when creating an instance of this classA Tooltip config object which is applied to the tooltip shown when hovering a TimeRange header element
Has a corresponding runtime hoverTooltip property.
The listener set for this object.
An object whose property names are the names of events to handle, or options which modifiy how the handlers are called.
See addListener for details about the options.
Listeners can be specified in target class config and they will be merged with any listeners specified in the instantiation config. Class listeners will be fired first:
class MyStore extends Store({
static configurable = {
listeners : {
myCustomEvent() {
},
load : {
prio : 10000,
fn() { // this load listener handles things first }
}
}
};
});
let store = new MyStore({
listeners: {
load: () => { // This load listener runs after the class's },
...
}
});
Handlers as function name
Object event handlers may be specified as a function name. If a string is specified, it is the name of the function in the thisObj object.
If the string begins with up., this object's ownership hierarchy (if present) is scanned for an object which implements that function name:
new Popup({
tbar : {
items : {
myCombo : {
type : 'combo',
editable : false,
label : 'Type',
listeners : {
// Look in owner chain for this function name
change : 'up.onFilterChange'
},
items : [
'Event',
'Task',
'Appointment'
]
}
}
},
items : {
...
},
onFilterChange({ value }) {
// Handle event type selection here
}
});
Template used to generate the tooltip contents when hovering the time selection header element.
const scheduler = new Scheduler({
features : {
timeSelection : {
tooltipTemplate({ startDate, endDate }) {
const count = this.client.getAvailableResources(startDate, endDate).length;
return `${count || 'No'} available resource(s)`;
}
}
}
});
Specify true to enable a drag-drop gesture to select the time span.
Has a corresponding runtime enableDragSelect property.
The selected time span, which can be set using simple startDate and endDate properties
Has a corresponding runtime selectedTimeSpan property.
By default, if an event handler throws an exception, the error propagates up the stack and the application state is undefined. Code which follows the event handler will not be executed.
Set this to true to catch exceptions thrown by this object's event handlers and continue processing the event. The exception will be rethrown on a zero millisecond timeout, so it will not destroy the stack.
Has a corresponding runtime catchEventHandlerExceptions property.
Internal listeners, that cannot be removed by the user.
An object where property names with a truthy value indicate which events should bubble up the ownership hierarchy when triggered.
const container = new Container({
items : [
{ type : 'text', bubbleEvents : { change : true }}
],
listeners : {
change() {
// Will catch change event from the text field
}
}
});
Set to true to call onXXX method names (e.g. onShow, onClick), as an easy way to listen for events.
const container = new Container({
callOnFunctions : true
onHide() {
// Do something when the 'hide' event is fired
}
});
Has a corresponding runtime callOnFunctions property.
The widget which this plugin is to attach to.
Has a corresponding runtime client property.
A class translations of which are used for translating this entity. This is often used when translations of an item are defined on its container class. For example:
// Toolbar class that has some predefined items
class MyToolbar extends Toolbar {
static $name = 'MyToolbar';
static configurable = {
// this specifies default configs for the items
defaults : {
// will tell items to use the toolbar locale
localeClass : this
},
items : {
// The toolbar has 2 buttons and translation for their texts will be searched in
// the toolbar locales
agree :{ text : 'Agree' },
disagree :{ text : 'Disagree' }
}
};
...
}
So if one makes a locale for the MyToolbar class that will include Agree and Disagree string translations:
...
MyToolbar : {
Agree : 'Yes, I agree',
Disagree : 'No, I do not agree'
}
They will be used for the toolbar buttons and the button captions will say Yes, I agree and No, I do not agree.
Set to false to disable localization of this object.
List of properties which values should be translated automatically upon a locale applying. In case there is a need to localize not typical value (not a String value or a field with re-defined setter/getter), you could use 'localeKey' meta configuration. Example:
static configurable = {
localizableProperties : ['width'],
width : {
value : '54em', // default value here
$config : {
localeKey : 'L{editorWidth}' // name of the property that will be used in localization file
}
}
};
Properties
Properties are getters/setters or publicly accessible variables on this class-
Identifies an object as an instance of Delayable class, or subclass thereof.
-
Identifies an object as an instance of Events class, or subclass thereof.
-
Identifies an object as an instance of Localizable class, or subclass thereof.
-
Identifies an object as an instance of TimeSelection class, or subclass thereof.
-
A class property getter for the default values of internal properties for this class.
-
Specify
trueto enable a drag-drop gesture to select the time span.Has a corresponding enableDragSelect config.
-
The Tooltip instance shown when hovering a TimeRange header element
Has a corresponding hoverTooltip 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 AbstractTimeRanges class, or subclass thereof.
-
Identifies an object as an instance of InstancePlugin class, or subclass thereof.
-
Identifies an object as an instance of TimeSelection class, or subclass thereof.
-
Returns a copy of the full configuration which was used to configure this object.
-
This property is set to
truebefore theconstructorreturns. -
This property is set to
trueon entry to the destroy method. It remains on the objects after returning fromdestroy(). If isDestroyed istrue, this property will also betrue, 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
-
Auto detaches listeners registered from start, if set as detachable
-
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 codeEvent handlers
Event handlers are callbacks called as a result of certain actions in this classCSS variables
CSS variables that can be set to adjust appearance| Name | Description |
|---|---|
| --b-time-selection-background | Time selection body background color |
| --b-time-selection-header-background | Time selection header background |
| --b-time-selection-opacity | Time selection body opacity |