EventStore

A store holding all the events to be rendered into a Scheduler.

This store only accepts a model class inheriting from EventModel.

An EventStore is usually connected to a project, which binds it to other related stores (AssignmentStore, ResourceStore and DependencyStore). The project also handles normalization/calculation of the data on the records in the store. For example if a record is added with a startDate and an endDate, it will calculate the duration.

The calculations happens async, records are not guaranteed to have up to date data until they are finished. To be certain that calculations have finished, call await project.commitAsync() after store actions. Or use one of the xxAsync functions, such as loadDataAsync().

Using commitAsync():

eventStore.data = [{ startDate, endDate }, ...];

// duration of the record is not yet calculated

await eventStore.project.commitAsync();

// now it is

Using loadDataAsync():

await eventStore.loadDataAsync([{ startDate, endDate }, ...]);

// duration is calculated

Using recurring events

When recurring events are in the database, all recurring event definitions which started before the requested start date, and have not yet finished recurring MUST be loaded into the EventStore.

Only the base recurring event definitions are stored in the EventStore. You do not need to calculate the future occurrence dates of these events. This is all handled by the EventStore.

When asked to yield a set of events for a certain date range for creating a UI through getEvents, the EventStore automatically interpolates any occurrences of recurring events into the results. They do not occupy slots in the EventStore for every date in their repetition range (that would be very inefficient, and might be infinite).

Configs

82

Common

Class used to represent records

Configure with true to also remove the event when removing the last assignment from the linked AssignmentStore. This config has no effect when using EventStore in legacy resourceId-mode.

Configure with true to force single-resource mode, an event can only be assigned to a single resource. If not provided, the mode will be inferred from

  1. presence of an assignment store (i.e. multi-assignment)
  2. presence of resourceId in the event store data (i.e. single assignment mode)
autoCommitStoreCRUD
autoLoadAjaxStore
dataStore
fieldsStore
groupersStoreGroup
idStore
listenersEvents
sortersStoreSort

Advanced

stmStoreStm
storageStore
useLocaleSortStoreSort

Chained store

chainedFieldsStoreChained
chainedFilterFnStoreChained
chainFiltersStoreChained
dontRelayToMasterStoreChained
doRelayToMasterStoreChained
ignoreLinkRecordsStoreChained
masterStoreStoreChained
syncOrderStoreChained
syncSortStoreChained

CRUD

createUrlAjaxStore
deleteUrlAjaxStore
readUrlAjaxStore
updateUrlAjaxStore

Filtering

filtersStoreFilter
remoteFilterStoreFilter

Misc

Other

lazyLoadAjaxStore
useSparseIndexStoreSparseIndex

Paging

pageParamNameStorePaging
pageSizeStorePaging
remotePagingStorePaging

Records

Remote

fetchOptionsAjaxStore
filterParamNameStoreFilter
headersAjaxStore
httpMethodsAjaxStore
paramsAjaxStore
paramsInBodyAjaxStore
restfulFilterAjaxStore

Sorting

remoteSortStoreSort
sortParamNameStoreSort

Tree

treeStore

Properties

79

Common

idStore

Class hierarchy

isEventStore: Boolean= truereadonly
Identifies an object as an instance of EventStore class, or subclass thereof.
isEventStore: Boolean= truereadonlystatic
Identifies an object as an instance of EventStore class, or subclass thereof.
isEventStoreMixin: Boolean= truereadonlyEventStoreMixin
Identifies an object as an instance of EventStoreMixin class, or subclass thereof.
isEventStoreMixin: Boolean= truereadonlystaticEventStoreMixin
Identifies an object as an instance of EventStoreMixin class, or subclass thereof.
isAjaxStoreAjaxStore
isEventsEvents
isGetEventsMixinGetEventsMixin
isPartOfProjectPartOfProject
isRecurringEventsMixinRecurringEventsMixin
isStoreStore
isStoreChainedStoreChained
isStoreChangesStoreChanges
isStoreCRUDStoreCRUD
isStoreFilterStoreFilter
isStoreGroupStoreGroup
isStorePagingStorePaging
isStoreRelationStoreRelation
isStoreSearchStoreSearch
isStoreSortStoreSort
isStoreSparseIndexStoreSparseIndex
isStoreStateStoreState
isStoreStmStoreStm
isStoreSumStoreSum
isStoreSyncStoreSync
isStoreTreeStoreTree

Records

Applies a new dataset to the EventStore. Use it to plug externally fetched data into the store.

NOTE: Dates, durations and relations (assignments, resources) on the events are determined async by a calculation engine. Thus they cannot be directly accessed after assigning the new dataset.

For example:

eventStore.data = [{ startDate, duration }];
// eventStore.first.endDate is not yet calculated

To guarantee data is in a calculated state, wait for calculations for finish:

eventStore.data = [{ startDate, duration }];
await eventStore.project.commitAsync();
// eventStore.first.endDate is calculated

Alternatively use loadDataAsync() instead:

await eventStore.loadDataAsync([{ startDate, duration }]);
// eventStore.first.endDate is calculated

Class used to represent records. Defaults to class EventModel.

autoCommitStoreCRUD
changesStoreCRUD
countStore
firstStore
hasChangesStoreCRUD
lastStore
recordsStore

Advanced

isChainedStoreChained
StopBranchstaticStoreTree

CRUD

createUrlAjaxStore
deleteUrlAjaxStore
isCommittingAjaxStore
isLoadingAjaxStore
readUrlAjaxStore
updateUrlAjaxStore

Filtering

Lifecycle

configBase

Misc

Models & Stores

assignmentStorePartOfProject
dependencyStorePartOfProject
eventStorePartOfProject
projectPartOfProject
resourceStorePartOfProject

Other

currentPageStorePaging
jsonStore
lazyLoadAjaxStore
storesstaticStore

Paging

isPagedStorePaging
lastPageStorePaging
pageSizeStorePaging

Remote

paramsAjaxStore

Sort, group & filter

filtersStoreFilter
groupersStoreGroup
isFilteredStoreFilter
isGroupedStoreGroup
isSortedStoreSort
sortersStoreSort

Tree

isTreeStoreTree
leavesStoreTree

Functions

122

Assignment

Creates and adds assignment record for a given event and a resource.

ParameterTypeDescription
eventEventModel | String | Number
resourceResourceModel | String | Number | ResourceModel[] | String[] | Number[]

The resource(s) to assign to the event

removeExistingAssignmentsBoolean

true to first remove existing assignments

Returns: AssignmentModel[] -

An array with the created assignment(s)

Returns all assignments for a given event.

ParameterTypeDescription
eventEventModel

The event to get assignments for

Returns: AssignmentModel[] -

Array of assignments for the event

Returns all assignments for a given resource.

ParameterTypeDescription
resourceResourceModel | String | Number
Returns: AssignmentModel[]

Checks whether an event is assigned to a resource.

ParameterTypeDescription
eventEventModel | String | Number
resourceResourceModel | String | Number
Returns: Boolean

Reassigns an event from an old resource to a new resource

ParameterTypeDescription
eventEventModel

An event or id of the event to reassign

oldResourceResourceModel | ResourceModel[]

A resource or id to unassign from

newResourceResourceModel | ResourceModel[]

A resource or id to assign to

Removes all assignments for given event

ParameterTypeDescription
eventEventModel | String | Number

Removes all assignments for given resource

ParameterTypeDescription
resourceResourceModel | String | Number

Removes assignment record for a given event and a resource.

ParameterTypeDescription
eventEventModel | String | Number
resourceResourceModel | String | Number

CRUD

Add events to the store.

NOTE: Dates, durations and references (assignments, resources) on the events are determined async by a calculation engine. Thus they cannot be directly accessed after using this function.

For example:

eventStore.add({ startDate, duration });
// endDate is not yet calculated

To guarantee data is in a calculated state, wait for calculations for finish:

eventStore.add({ startDate, duration });
await eventStore.project.commitAsync();
// endDate is calculated

Alternatively use addAsync() instead:

await eventStore.addAsync({ startDate, duration });
// endDate is calculated
ParameterTypeDescription
recordsEventModel | EventModel[] | EventModelConfig | EventModelConfig[]

Array of records/data or a single record/data to add to store

silentBoolean

Specify true to suppress events

Returns: EventModel[] -

Added records

Add events to the store and triggers calculations directly after. Await this function to have up to date data on the added events.

await eventStore.addAsync({ startDate, duration });
// endDate is calculated
ParameterTypeDescription
recordsEventModel | EventModel[] | EventModelConfig | EventModelConfig[]

Array of records/data or a single record/data to add to store

silentBoolean

Specify true to suppress events

Returns: EventModel[] -

Added records

Appends a new record to the store

ParameterTypeDescription
recordEventModel

The record to append to the store

Applies a new dataset to the EventStore and triggers calculations directly after. Use it to plug externally fetched data into the store.

await eventStore.loadDataAsync([{ startDate, duration }]);
// eventStore.first.endDate is calculated
ParameterTypeDescription
dataEventModelConfig[]

Array of EventModel data objects

applyChangesetStoreChanges
commitAjaxStore
insertStoreCRUD
loadAjaxStore
loadChildrenAjaxStore
loadPageAjaxStore
moveStoreCRUD
nextPageStorePaging
previousPageStorePaging
removeStoreCRUD
removeAllStoreCRUD
revertChangesStoreCRUD

Events

Calls the supplied iterator function once for every scheduled event, providing these arguments

  • event : the event record
  • startDate : the event start date
  • endDate : the event end date

Returning false cancels the iteration.

ParameterTypeDescription
fnfunction

iterator function

thisObjObject

this reference for the function

Returns a Map, keyed by YYYY-MM-DD date keys containing event counts for all the days between the passed startDate and endDate. Occurrences of recurring events are included.

Example:

 eventCounts = eventStore.getEventCounts({
     startDate : scheduler.timeAxis.startDate,
     endDate   : scheduler.timeAxis.endDate
 });
ParameterTypeDescription
optionsObject

An options object determining which events to return

options.startDateDate

The start date for the range of events to include.

options.endDateDate

The end date for the range of events to include.

Returns an object defining the earliest start date and the latest end date of all the events in the store.

Returns: Object -

An object with 'startDate' and 'endDate' properties (or null values if data is missing).

Checks if given event record is persistable. By default it always is, override EventModels isPersistable if you need custom logic.

ParameterTypeDescription
eventEventModel
Returns: Boolean
getEventsGetEventsMixin

Resource

Returns all events assigned to a resource. NOTE: this does not include occurrences of recurring events. Use the getEvents API to include occurrences of recurring events.

ParameterTypeDescription
resourceResourceModel | String | Number

Resource or resource id.

Returns: EventModel[]

Returns all resources assigned to an event.

ParameterTypeDescription
eventEventModel | String | Number
Returns: ResourceModel[]
isDateRangeAvailableGetEventsMixin

Chained store

chainStoreChained
chainTreeStoreChained
fillFromMasterStoreChained

Configuration

applyDefaultsstaticBase

Iteration

everyStore
flatMapStore
forEachStore
mapStore
reduceStore

Lifecycle

destroystaticBase

Misc

initClassstaticBase
isOfTypeNamestaticBase
mixinstaticBase

Other

getStorestaticStore
onEvents
relayAllEvents
toJSONStore
triggerEvents
unEvents

Records

getAtStore
getByIdStore
indexOfStore

Recurrence

getRecurringEventsRecurringEventsMixin

Search

findStoreSearch
findByFieldStoreSearch
findRecordStoreSearch
queryStoreSearch
searchStoreSearch
someStoreSearch

Sort, group & filter

addFilterStoreFilter
addSorterStoreSort
clearFiltersStoreFilter
clearGroupersStoreGroup
clearSortersStoreSort
filterStoreFilter
filterByStoreFilter
getGroupRecordsStoreGroup
getGroupTitlesStoreGroup
groupStoreGroup
isRecordInGroupStoreGroup
removeFilterStoreFilter
removeSorterStoreSort
setGroupersStoreGroup
sortStoreSort

Sum

averageStoreSum
groupSumStoreSum
maxStoreSum
minStoreSum
sumStoreSum

Traverse

getNextStore
getPrevStore

Tree

getChildrenStoreTree
indentStoreTree
outdentStoreTree

Values

Events

46
addStoreCRUD
beforeAddStoreCRUD
beforeCommitStoreCRUD
beforeFilterStoreFilter
beforeIndentStoreTree
beforeLoadAjaxStore
beforeLoadPageStorePaging
beforeOutdentStoreTree
beforeRemoveStoreCRUD
beforeSortStoreSort
catchAllEvents
changeStore
commitStoreCRUD
commitAddedAjaxStore
commitRemovedAjaxStore
destroyEvents
exceptionAjaxStore
filterStoreFilter
groupStoreGroup
indentStoreTree
loadAjaxStore
loadChildrenAjaxStore
loadDateRangeGetEventsMixin
loadPageStorePaging
loadPageStartAjaxStore
loadStartAjaxStore
moveStore
outdentStoreTree
refreshStore
removeStoreCRUD
removeAllStoreCRUD
sortStoreSort
updateStore

Event handlers

46
onAddStoreCRUD
onBeforeAddStoreCRUD
onBeforeFilterStoreFilter
onBeforeLoadAjaxStore
onBeforeLoadPageStorePaging
onBeforeSortStoreSort
onCommitStoreCRUD
onCommitAddedAjaxStore
onDestroyEvents
onExceptionAjaxStore
onFilterStoreFilter
onGroupStoreGroup
onIndentStoreTree
onLoadAjaxStore
onLoadDateRangeGetEventsMixin
onLoadPageStorePaging
onLoadStartAjaxStore
onMoveStore
onOutdentStoreTree
onRemoveStoreCRUD
onRemoveAllStoreCRUD
onSortStoreSort

Typedefs

9