GetEventsMixin

Properties

2
isGetEventsMixin: Boolean= truereadonly
Identifies an object as an instance of GetEventsMixin class, or subclass thereof.
isGetEventsMixin: Boolean= truereadonlystatic
Identifies an object as an instance of GetEventsMixin class, or subclass thereof.

Functions

3

Events

Returns an array of events for the date range specified by the startDate and endDate options.

By default, for any date, this includes any event which intersects that date.

To only include events that are fully contained within the date range, pass the allowPartial option as false.

By default, any occurrences of recurring events are included in the resulting array (not applicable in Gantt). If that is not required, pass the includeOccurrences option as false.

Note that if includeOccurrences is true, the start date and end date options are mandatory. The method must know what range of occurrences needs to be generated and returned.

Example:

 visibleEvents = eventStore.getEvents({
     resourceRecord : myResource,
     startDate      : scheduler.timeAxis.startDate,
     endDate        : scheduler.timeAxis.endDate
 });
ParameterTypeDescription
optionsObject

An options object determining which events to return

options.dateDate

If only one date is required, pass this option instead of the startDate and endDate options.

options.startDateDate

The start date for the range of events to include.

options.endDateDate

The end date for the range of events to include. Defaults to a startDate + one day range if only startDate passed

options.resourceRecordResourceModel

Pass a resource to only return events assigned to this resource. Not supported when using the dateMap option (see below)

options.filterfunction

A function to filter out events which are not required.

options.ignoreFiltersBoolean

By default, store filters are honoured. Pass this as true to include filtered out events.

options.includeOccurrencesBoolean

Occurrences of recurring events are included by default.

options.allowPartialBoolean

Events which start before or after the range, but intersect the range are included by default.

options.startOnlyBoolean

Pass true to only include events which start on each date in the range.

options.silentBoolean

Pass true to not fire the loadDateRange event.

options.onlyAssignedBoolean

Pass true to only include events that are assigned to a resource

options.dateMapBoolean | Map

Populates the passed Map, or if passed as true, creates and returns a new Map. The keys are YYYY-MM-DD date strings and the entries are arrays of EventModels.

Returns: EventModel[] | Map -

Events which match the passed configuration.

Other

This function will find the next available start date where the provided duration fits without causing any conflicts. It begins by checking the provided resources on the provided startDate. And if any conflicting events is found, it restarts searching from the last of the conflicting events and continues like this until a matching time slot is found.

ParameterTypeDescription
optionsObject
options.startDateDate

The date from which to start looking for available date range

options.durationDurationConfig | string

The duration of the slot to look for

options.resourcesResourceModel[]

The resources to include in the search

options.matchAllResourcesBoolean

Set to true to require all resources to be available

options.stopDateDate

The date to stop looking for available date ranges. Defaults to 10 years from Date.now()

options.isConflictfunction

An optional function which will be called for each conflicting event, making it possible to return false to ignore that event from the search

options.getValidDatefunction

An optional function which will be called for each date ranged that will be searched for availability. Useful for not allowing certain time slots to be included, like nighttime or lunch-breaks. Return the new startDate to make the search skip certain time ranges.

Returns: Object | undefined -

{ startDate, resource } - If an available date range is found, an object will be return containing a matching resource (only if matchAllResources = false) and the startDate of the date range.

Resource

Checks if a date range is available for a given resource.

Note that when asked to check a 0 duration range, any 0 duration events at the same point in time will be considered overlapping.

ParameterTypeDescription
startDateDate

The start date

endDateDate

The end date

excludeEventEventModel | EventModel[] | null

An event to exclude from the check (or null)

resourceRecordResourceModel | ResourceModel[]

The resource

Returns: Boolean -

True if the timespan is available for the resource

Events

1

Fired when a range of events is requested from the getEvents method.

This event fires every time a range of events is requested from the store.

An application may have one of two levels of interest in events being read from a store.

  1. To be notified when any event block is requested regardless of what the date range is.
  2. To be notified when a new date range is requested.

This event allows both types of application to be written. The changed property is set if a different date range is requested.

new Scheduler({
    eventStore : {
        listeners : {
            loadDateRange({ new : { startDate, endDate }, changed }) {
                // Load new data if user is requesting a different time window.
                if (changed) {
                    fetch(...);
                }
            }
        }
    },
    ...
});
// Adding a listener using the "on" method
getEventsMixin.on('loadDateRange', ({ source, old, old.startDate, old.endDate, new, new.startDate, new.endDate, changed }) => {

});
ParameterTypeDescription
sourceEventStore

This EventStore

oldObject

The old date range

old.startDateDate

the old start date

old.endDateDate

the old end date

newObject

The new date range

new.startDateDate

the new start date

new.endDateDate

the new end date

changedBoolean

true if the date range is different from the last time a request was made

Event handlers

1

Called when a range of events is requested from the getEvents method.

This event called every time a range of events is requested from the store.

An application may have one of two levels of interest in events being read from a store.

  1. To be notified when any event block is requested regardless of what the date range is.
  2. To be notified when a new date range is requested.

This event allows both types of application to be written. The changed property is set if a different date range is requested.

new Scheduler({
    eventStore : {
        listeners : {
            loadDateRange({ new : { startDate, endDate }, changed }) {
                // Load new data if user is requesting a different time window.
                if (changed) {
                    fetch(...);
                }
            }
        }
    },
    ...
});
new GetEventsMixin({
    onLoadDateRange({ source, old, new, changed }) {

    }
});
ParameterTypeDescription
sourceEventStore

This EventStore

oldObject

The old date range

old.startDateDate

the old start date

old.endDateDate

the old end date

newObject

The new date range

new.startDateDate

the new start date

new.endDateDate

the new end date

changedBoolean

true if the date range is different from the last time a request was made