EventModelMixin
Properties
11
Properties
11Assignments & Resources
Returns all assignments for the event. Event must be part of the store for this method to work.
Returns the first assigned resource, or assigns a resource
Returns all resources assigned to an event.
Class hierarchy
Dependencies
Returns all predecessor dependencies of this event
Returns all successor dependencies of this event
Editing
Returns true if event can be drag and dropped
Returns false if the event is not persistable. By default it always is, override this getter if you need
custom logic.
Returns true if event can be resized, but can additionally return 'start' or 'end' indicating how this event can be resized.
Milestones and parent events (that are not manuallyScheduled) cannot be resized.
Scheduling
Flag which indicates that this event is an interday event. This means that it spans an entire day or multiple days.
This is essentially used by the Calendar package to determine if an event should go into the all day zone of a DayView.
Functions
8
Functions
8Assignments & Resources
Assigns this event to the specified resource.
Note: The event must be part of an EventStore for this to work. If the EventStore uses single assignment (loaded using resourceId) existing assignments will always be removed.
| Parameter | Type | Description |
|---|---|---|
resource | ResourceModel | String | Number | ResourceModel[] | String[] | Number[] | A new resource for this event, either as a full Resource record or an id (or an array of such). |
removeExistingAssignments | Boolean |
|
Returns either the resource associated with this event (when called w/o resourceId) or resource
with specified id.
| Parameter | Type | Description |
|---|---|---|
resourceId | String | To retrieve a specific resource |
Returns true if this event is assigned to a certain resource.
| Parameter | Type | Description |
|---|---|---|
resource | ResourceModel | String | Number | The resource to query for |
Reassigns an event from an old resource to a new resource
| Parameter | Type | Description |
|---|---|---|
oldResourceId | ResourceModel | String | Number | A resource to unassign from or its id |
newResourceId | ResourceModel | String | Number | A resource to assign to or its id |
Unassigns this event from the specified resource
| Parameter | Type | Description |
|---|---|---|
resource | ResourceModel | String | Number | The resource to unassign from. |
Editing
Defines if the given event field should be manually editable in UI. You can override this method to provide your own logic.
By default, the method defines endDate, duration and fullDuration fields editable for leaf events only (in case the event is part of a tree store) and all other fields as editable.
| Parameter | Type | Description |
|---|---|---|
fieldName | String | Name of the field |
Returns true if the field is editable, false if it is not and undefined if the event has
no such field.
Set value for the specified field(s), triggering engine calculations immediately. See Model#set() for arguments.
eventRecord.set('duration', 4);
// eventRecord.endDate is not yet calculated
await eventRecord.setAsync('duration', 4);
// eventRecord.endDate is calculated
| Parameter | Type | Description |
|---|---|---|
field | String | Object | The field to set value for, or an object with multiple values to set in one call |
value | * | Value to set |
silent | Boolean | Set to |
Scheduling
Shift the dates for the date range by the passed amount and unit
| Parameter | Type | Description |
|---|---|---|
amount | Number | The amount to shift |
unit | DurationUnitShort | The unit to shift by, see DateHelper for more information on valid formats. |
A promise which is resolved when shift calculations are done
Typedefs
1
Typedefs
1Predefined named colors:
Fields
15
Fields
15Common
The unique identifier of a task (mandatory)
Id of the resource this event is associated with (only usable for single assignments). We recommend
using assignments in an AssignmentStore over this approach. Internally any Event using resourceId
will have an assignment in AssignmentStore generated.
Ids of the resources this event is associated with (can be used for for multiple assignments).
Any event using resourceIds will have assignments in AssignmentStore generated automatically.
It only applies if is configured with persist: true.
class CustomEventModel extends EventModel {
static $name = 'CustomEventModel';
static get fields() {
return [
{ name : 'resourceIds', persist : true }
];
}
};
const
resources = [
{ id : 'r1', name : 'Celia' },
{ id : 'r2', name : 'Lee' },
{ id : 'r3', name : 'Macy' },
{ id : 'r4', name : 'Madison' }
],
events = [
{
id : 1,
resourceIds : ['r1', 'r2']
...
},
{
id : 2,
resourceIds : ['r3', 'r4']
...
}
];
const scheduler = new Scheduler({
...
eventStore : {
modelClass : CustomEventModel,
data : events
},
...
});
The array of resources which are assigned to this event.
Interaction
Specify false to prevent the event from being dragged (if EventDrag feature is used)
Specify false to prevent the event from being resized (if EventResize feature is used). You can also
specify 'start' or 'end' to only allow resizing in one direction
Scheduling
A field marking event as all day(s) spanning event.
For example, a holiday day may be represented by a startDate, and the allDay flag.
The numeric part of the timespan's duration (the number of units).
UI fields representing this data field are disabled for summary tasks. See isEditable for details.
The end date of a time span (or Event / Task).
Uses DateHelper.defaultFormat to convert a supplied string to a Date. To specify another format, either change that setting or subclass TimeSpan and change the dateFormat for this field.
UI fields representing this data field are disabled for summary tasks. See isEditable for details.
Note that the field always returns a Date.
Calculated field which encapsulates the duration's magnitude and unit. This field will not be persisted, setting it will update the duration and durationUnit fields.
UI fields representing this data field are disabled for summary tasks. See isEditable for details.
The start date of a time span (or Event / Task).
Uses DateHelper.defaultFormat to convert a supplied string to a Date. To specify another format, either change that setting or subclass TimeSpan and change the dateFormat for this field.
UI fields representing this data field are disabled for summary tasks. See isEditable for details.
Note that the field always returns a Date.
Also note that modifying the startDate at runtime will move the event in time, without affecting its
duration (with reservation for other scheduling logic affecting the duration). If you want to change the
startDate and duration, use setStartDate instead (passing
false as the second argument).
Styling
Controls the primary color of the event. For available standard colors, see EventColor.
Controls this events appearance, see Schedulers eventStyle config for available options.
Width (in px) to use for this milestone when using Scheduler#milestoneLayoutMode 'data'.
Set this field to false to opt out of sticky event content
(keeping event text in view while scrolling).