EventModelMixin

Properties

11

Assignments & 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

isEventModelMixin: Boolean= truereadonly
Identifies an object as an instance of EventModelMixin class, or subclass thereof.
isEventModelMixin: Boolean= truereadonlystatic
Identifies an object as an instance of EventModelMixin class, or subclass thereof.

Dependencies

Returns all predecessor dependencies of this event

Returns all successor dependencies of this event

Editing

isDraggable: Boolean

Returns true if event can be drag and dropped

isPersistable: Booleanreadonly

Returns false if the event is not persistable. By default it always is, override this getter if you need custom logic.

isResizable: Boolean | Stringreadonly

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

isInterDay: Booleanreadonly

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

Assignments & 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.

ParameterTypeDescription
resourceResourceModel | 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).

removeExistingAssignmentsBoolean

true to first remove existing assignments

Returns either the resource associated with this event (when called w/o resourceId) or resource with specified id.

ParameterTypeDescription
resourceIdString

To retrieve a specific resource

Returns: ResourceModel

Returns true if this event is assigned to a certain resource.

ParameterTypeDescription
resourceResourceModel | String | Number

The resource to query for

Returns: Boolean

Reassigns an event from an old resource to a new resource

ParameterTypeDescription
oldResourceIdResourceModel | String | Number

A resource to unassign from or its id

newResourceIdResourceModel | String | Number

A resource to assign to or its id

Unassigns this event from the specified resource

ParameterTypeDescription
resourceResourceModel | 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.

ParameterTypeDescription
fieldNameString

Name of the field

Returns: Boolean -

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
ParameterTypeDescription
fieldString | Object

The field to set value for, or an object with multiple values to set in one call

value*

Value to set

silentBoolean

Set to true to not trigger events. If event is recurring, occurrences won't be updated automatically.

Scheduling

Shift the dates for the date range by the passed amount and unit

ParameterTypeDescription
amountNumber

The amount to shift

unitDurationUnitShort

The unit to shift by, see DateHelper for more information on valid formats.

Returns: Promise -

A promise which is resolved when shift calculations are done

Typedefs

1
EventColor: red | pink | magenta | purple | violet | deep-purple | indigo | blue | light-blue | cyan | teal | green | light-green | lime | yellow | orange | amber | deep-orange | light-gray | gray | black | String | null

Predefined named colors:

red
pink
magenta
purple
violet
deep-purple
indigo
blue
light-blue
cyan
teal
green
light-green
lime
yellow
orange
amber
deep-orange
light-gray
gray
black

Fields

15

Common

id: String | Number

The unique identifier of a task (mandatory)

resourceId: String | Number

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.

resourceIds: String[] | Number[]

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

draggable: Boolean= true

Specify false to prevent the event from being dragged (if EventDrag feature is used)

resizable: Boolean | String= true

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

allDay: Boolean

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.

duration: Number

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.

endDate: Date

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.

startDate: Date

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

eventColor: EventColor | String | null

Controls the primary color of the event. For available standard colors, see EventColor.

eventStyle: plain | border | colored | hollow | line | dashed | minimal | rounded | calendar | interday | gantt | null

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).