EventSegments
This feature provides segmented events support. It implements rendering of such events and also adds a entries to the event context menu allowing to split the selected event and rename segments.
Note: this feature is not compatible with Revisions feature.
//<code-header>
fiddle.title = 'Event segments';
//</code-header>
const schedulerPro = new SchedulerPro({
appendTo : targetElement,
// makes scheduler as high as it needs to be to fit rows
autoHeight : true,
startDate : new Date(2022, 2, 20),
endDate : new Date(2022, 2, 27),
columns : [
{ field : 'name', text : 'Name', width : 100 }
],
project : {
resources : [
{ id : 1, name : 'Bruce' },
{ id : 2, name : 'Diana' }
],
events : [
{
id : 1,
name : 'Art project',
startDate : '2022-03-21',
segments : [
{ startDate : '2022-03-21', duration : 1 },
{ startDate : '2022-03-23', duration : 1 },
{ startDate : '2022-03-25', duration : 1 }
]
},
{
id : 2,
name : 'DIY project',
startDate : '2022-03-21',
segments : [
// segments can have their own names & colors
{ name : 'Plan', startDate : '2022-03-21', duration : 1, eventColor : 'indigo' },
{ name : 'Get supplies', startDate : '2022-03-23', duration : 2 }
]
}
],
assignments : [
{ id : 1, event : 1, resource : 1 },
{ id : 7, event : 2, resource : 2 }
]
},
features : {
eventSegments : {
// split at the exact date user clicks in UI
roundedSplit : false
}
}
});This feature is enabled by default. For info on enabling it, see GridFeatures.
Configs
13
Configs
13Other
Maximum allowed split duration. The value is used when calculating split duration automatically.
Setting the config to zero means not limiting split duration max value.
The duration can be provided as Duration instance (or its configuration object) including both numeric and unit parts.
...
features : {
eventSegments : {
// split duration is automatic and changes depending on zoom level
// but we limit its maximum as 1 week
maxSplitDuration : {
magnitude : 1,
unit : "week"
}
}
...
Or it can be provided as a positive number which means it's expressed in the clicked event duration units.
Defaults to 1 day.
Minimum allowed split duration. The value is used when calculating split duration automatically.
Setting the config to zero (default) means not limiting split duration min value.
The duration can be provided as Duration instance (or its configuration object) including both numeric and unit parts.
...
features : {
eventSegments : {
// split duration is automatic and changes depending on zoom level
// limit its minimum as 1 hour
minSplitDuration : {
magnitude : 1,
unit : "hour"
}
// we limit its maximum as 1 day
maxSplitDuration : {
magnitude : 1,
unit : "day"
}
}
...
Or it can be provided as a positive number which means it's expressed in the clicked event duration units.
If true, it uses rounded dates when splitting
The split duration to be used when "Split event" menu item is called. When set to zero (default) the duration is calculated automatically as the clicked tick duration restricted by minSplitDuration and maxSplitDuration values.
The duration can be provided as Duration instance (or its configuration object) including both numeric and unit parts.
...
features : {
eventSegments : {
// split events by 1 day
splitDuration : {
magnitude : 1,
unit : "day"
}
}
...
Or it can be provided as a positive number which means it's expressed in the clicked event duration units.
Misc
Properties
16
Properties
16Common
Class hierarchy
Other
If true, it uses rounded dates when splitting
Functions
31
Functions
31Other
Returns a date at which to split an event.
Returns start date of the tick being clicked if the tick duration is less than maxSplitDuration
or maxSplitDuration is zero.
When the tick duration is greater than maxSplitDuration returns context.date rounded based on
active time axis resolution unit.
Override this method if you want to implement another way of calculating the split date.
See also: getSplitDuration, getSplitDurationUnit.
| Parameter | Type | Description |
|---|---|---|
context | Object | Split function-call context |
context.eventRecord | EventModel | Event being split |
context.point | Array | Click position. Array containing [x, y] coordinates of mouse click. |
context.date | Date | Date corresponding to the click position. |
context.tick | Object | Time axis tick corresponding to the click position. |
context.timeAxis | TimeAxis | Time axis instance. |
Returns a date to be used to split.
Returns the event split duration.
If splitDuration value is provided:
- as a
Numberthe method returns the value as is - as an
Objector Duration instance - the method returns the valueunitpart
If splitDuration is NOT provided the method returns the clicked tick duration constrained by minSplitDuration and maxSplitDuration values.
Override this method if you want to implement another way of the split duration calculating.
See also: getSplitDate, getSplitDurationUnit.
| Parameter | Type | Description |
|---|---|---|
context | Object | Split call context |
context.eventRecord | EventModel | Event being split |
context.point | Array | Click position. Array containing [x, y] coordinates of mouse click. |
context.date | Date | Date corresponding to the click position. |
context.tick | Object | Time axis tick corresponding to the click position. |
context.timeAxis | TimeAxis | Time axis instance. |
Returns split duration.
Returns the duration unit to be used for the event splitting.
When splitDuration is provided as Duration instance or its configuration Object:
...
features : {
eventSegments : {
// split events by 1 day
splitDuration : {
magnitude : 1,
unit : "day"
}
}
...
}
the method returns the value unit part otherwise it returns the event
durationUnit.
Override this method config-if you want to implement another way of the split duration unit defining.
See also: getSplitDate, getSplitDuration.
| Parameter | Type | Description |
|---|---|---|
context | Object | Split function-call context |
context.eventRecord | EventModel | Event being split |
context.point | Array | Click position. Array containing [x, y] coordinates of mouse click. |
context.date | Date | Date corresponding to the click position. |
context.tick | Object | Time axis tick corresponding to the click position. |
context.timeAxis | TimeAxis | Time axis instance. |
Returns split duration unit.
Configuration
Events
Misc
Events
5
Events
5Event handlers
5
Event handlers
5Typedefs
1
Typedefs
1CSS variables
4
CSS variables
4| Name | Description |
|---|---|
--b-segment-link-width | Event segment link width |
--b-segment-link-style | Event segment link style |
--b-segment-link-color | Event segment link color |
--b-segmented-background | Event segment background |