v7.3.0
SupportExamplesFree Trial

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

See also

No results

Configs

Configs are options you supply in a configuration object when creating an instance of this class
  • Commit changes automatically

    Has a corresponding runtime autoCommit property.

  • The timeout in milliseconds to wait before persisting changes to the server. Used when autoCommit is set to true.

  • True to initiate a load when the store is instantiated

  • groupers : Grouper[]
    NON-LAZY-LOAD
    StoreGroup

    Initial groupers, specify to have store grouped automatically after initially setting data

    Has a corresponding runtime groupers property.

  • Store's unique identifier. When set the store is added to a store map accessible through Store.getStore(id).

    Has a corresponding runtime id property.

  • Class used to represent records

    Has a corresponding runtime modelClass property.

  • 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)
  • Set to false to not record transaction during applyChangeset call

    Has a corresponding runtime ignoreRemoteChangesInSTM property.

  • Prevent dynamically subclassing the modelClass. It does so by default to not pollute it when exposing properties. Should rarely need to be used.

  • Reference to STM manager

  • A Collection, or Collection config object to use to contain this Store's constituent records.

  • If set to true, or a config object, this makes the store load new records when needed. When a record that is not already loaded is requested, the requestData function is called. Please read the guide to learn more on how to configure lazy loading.

    Parameters

    • bufferUnit : DurationUnit

      Used together with bufferAmount to calculate the start and end dates of each load request. The value is added to the current visible start or end date. Defaults to the visible time span length.

    • bufferAmount : Number

      See bufferUnit

    • dateFormat : String

      The format used to convert startDate and endDate parameters passed to the load request querystring. Defaults to YYYY-MM-DD (e.g. 2024-03-11). Only used if a readUrl is configured on the store. See DateHelper for details about formatting dates.

    • loadFullResourceRange : Boolean

      If the ResourceStore is not lazy loaded, set this to true to load events, assignments and/or resource time ranges for all resources with every load request.

    • useResourceIds : Boolean

      Set to true to always provide resourceIds in the request params, instead of a resource startIndex and count

  • CrudManager must load stores in the correct order. Lowest first.

  • CrudManager must sync stores in the correct order. Lowest first.

  • Internal listeners, that cannot be removed by the user.

  • Specify true to reapply filters when a record is added to or moved within the store. This includes tree node operations like indent/outdent in Gantt, or any move operation that changes a node's parent.

  • Specify true to reapply filters when a record is updated in the store. You can also provide an array of field names, to only re-filter when certain data fields are updated.

  • The name of the parameter to use when requesting pages of data using the zero based index of the required page's starting record.

  • pageSizeParamName : StringpageSize
    NON-LAZY-LOAD
    StorePaging

    The name of the parameter to use when requesting pages of data, representing the configured pageSize value.

  • The name of the parameter to use when requesting pages of data using the one based page number required.

  • An object containing key/value pairs that are passed on the request query string, or in the request body if HTTP method allows. See paramsInBody config.

    Has a corresponding runtime params property.

  • When this config is enabled, the params of "read" request are placed in the request body instead of the query string, if the HTTP method allows.

  • The name of the HTTP parameter passed to this Store's readUrl to indicate the node id to load when loading child nodes on demand if the node being expanded was created with data containing children: true.

  • Specify true to send payloads as form data, false to send as regular JSON.

  • Set to ´true´ to use restful httpMethods

  • Specify true to send all model fields when committing modified records (as opposed to just the modified fields)

  • Specify true to sort this store after records are added.

  • When set to true, restores the expanded states of tree nodes when reloading data.

  • autoTree : Booleantrue
    NON-LAZY-LOAD
    AjaxStore

    Automatically detect from set data if used as tree store or flat store. If tree is explicitly set to false, then this value will be overruled and no tree detection performed.

  • Set to true to fire a 'remove' event when moving a node (to mimic the behavior of versions < 6.0).

  • true to act as a tree store.

Properties

Properties are getters/setters or publicly accessible variables on this class
  • isEventStore : Booleantrue
    READONLY
    static
    ADVANCED
    Identifies an object as an instance of EventStore class, or subclass thereof.
  • isEventStoreMixin : Booleantrue
    READONLY
    static
    ADVANCED
    EventStoreMixin
    Identifies an object as an instance of EventStoreMixin class, or subclass thereof.
  • isEvents : Booleantrue
    READONLY
    static
    ADVANCED
    Events
    Identifies an object as an instance of Events class, or subclass thereof.
  • isGetEventsMixin : Booleantrue
    READONLY
    static
    ADVANCED
    GetEventsMixin
    Identifies an object as an instance of GetEventsMixin class, or subclass thereof.
  • isPartOfProject : Booleantrue
    READONLY
    static
    ADVANCED
    PartOfProject
    Identifies an object as an instance of PartOfProject class, or subclass thereof.
  • isRecurringEventsMixin : Booleantrue
    READONLY
    static
    ADVANCED
    RecurringEventsMixin
    Identifies an object as an instance of RecurringEventsMixin class, or subclass thereof.
  • isStoreCRUD : Booleantrue
    READONLY
    static
    ADVANCED
    StoreCRUD
    Identifies an object as an instance of StoreCRUD class, or subclass thereof.
  • isStoreChained : Booleantrue
    READONLY
    static
    ADVANCED
    StoreChained
    Identifies an object as an instance of StoreChained class, or subclass thereof.
  • isStoreChanges : Booleantrue
    READONLY
    static
    ADVANCED
    StoreChanges
    Identifies an object as an instance of StoreChanges class, or subclass thereof.
  • isStoreFilter : Booleantrue
    READONLY
    static
    ADVANCED
    StoreFilter
    Identifies an object as an instance of StoreFilter class, or subclass thereof.
  • isStoreGroup : Booleantrue
    READONLY
    static
    ADVANCED
    StoreGroup
    Identifies an object as an instance of StoreGroup class, or subclass thereof.
  • isStorePaging : Booleantrue
    READONLY
    static
    ADVANCED
    StorePaging
    Identifies an object as an instance of StorePaging class, or subclass thereof.
  • isStoreRelation : Booleantrue
    READONLY
    static
    ADVANCED
    StoreRelation
    Identifies an object as an instance of StoreRelation class, or subclass thereof.
  • isStoreSearch : Booleantrue
    READONLY
    static
    ADVANCED
    StoreSearch
    Identifies an object as an instance of StoreSearch class, or subclass thereof.
  • isStoreSort : Booleantrue
    READONLY
    static
    ADVANCED
    StoreSort
    Identifies an object as an instance of StoreSort class, or subclass thereof.
  • isStoreSparseIndex : Booleantrue
    READONLY
    static
    ADVANCED
    StoreSparseIndex
    Identifies an object as an instance of StoreSparseIndex class, or subclass thereof.
  • isStoreState : Booleantrue
    READONLY
    static
    ADVANCED
    StoreState
    Identifies an object as an instance of StoreState class, or subclass thereof.
  • isStoreStm : Booleantrue
    READONLY
    static
    ADVANCED
    StoreStm
    Identifies an object as an instance of StoreStm class, or subclass thereof.
  • isStoreSum : Booleantrue
    READONLY
    static
    ADVANCED
    StoreSum
    Identifies an object as an instance of StoreSum class, or subclass thereof.
  • isStoreSync : Booleantrue
    READONLY
    static
    ADVANCED
    StoreSync
    Identifies an object as an instance of StoreSync class, or subclass thereof.
  • isStoreTree : Booleantrue
    READONLY
    static
    ADVANCED
    StoreTree
    Identifies an object as an instance of StoreTree class, or subclass thereof.
  • properties : Object
    internal
    static
    AjaxStore

    A class property getter for the default values of internal properties for this class.

  • stores : Store[]
    READONLY
    static
    AjaxStore

    Get all registered stores

  • Store's unique identifier.

    Has a corresponding id config.

  • Returns the root store in the chain — the store that is not itself chained. For a store chained off another chained store, this walks up the full chain. Returns this if the store is not chained.

  • Set to false to not record transaction during applyChangeset call

    Has a corresponding ignoreRemoteChangesInSTM config.

  • isChained : Boolean
    READONLY
    NON-LAZY-LOAD
    StoreChained

    Is this a chained store?

  • Returns true if the data in this store depends on a remote data source. That is this Store is an AjaxStore, or uses requestData, or is chained off an AjaxStore.

  • emptyArray : Array
    internal
    READONLY
    AjaxStore

    An empty array that can be used as a default value.

  • emptyObject : Object
    internal
    READONLY
    AjaxStore

    An empty object that can be used as a default value.

  • Returns true if the Store is currently committing

  • isAjaxStore : Booleantrue
    READONLY
    ADVANCED
    AjaxStore
    Identifies an object as an instance of AjaxStore class, or subclass thereof.
  • isEventStore : Booleantrue
    READONLY
    ADVANCED
    Identifies an object as an instance of EventStore class, or subclass thereof.
  • Identifies an object as an instance of RecurringTimeSpansMixin class, or subclass thereof.
  • isStore : Booleantrue
    READONLY
    ADVANCED
    AjaxStore
    Identifies an object as an instance of Store class, or subclass thereof.
  • config : Object
    READONLY
    ADVANCED
    AjaxStore

    Returns a copy of the full configuration which was used to configure this object.

  • isConstructing : Boolean
    READONLY
    ADVANCED
    AjaxStore

    This property is set to true before the constructor returns.

  • isDestroying : Boolean
    READONLY
    ADVANCED
    AjaxStore

    This property is set to true on entry to the destroy method. It remains on the objects after returning from destroy(). If isDestroyed is true, this property will also be true, so there is no need to test for both (for example, comp.isDestroying || comp.isDestroyed).

  • Returns the assignment store of the project this entity belongs to.

  • Returns the dependency store of the project this entity belongs to.

  • Returns the event store of the project this entity belongs to.

  • Returns the project this entity belongs to.

  • Returns the resource store of the project this entity belongs to.

  • isPaged : Boolean
    READONLY
    NON-LAZY-LOAD
    StorePaging

    Yields true if this Store is loaded page by page. See the remotePaging config.

  • lastPage : Number
    READONLY
    NON-LAZY-LOAD
    StorePaging

    If the store is paged, yields the highest page number in the dataset as calculated from the 'total' returned in the last page data block loaded.

  • Returns all locally available records from the store, ignoring any filters and including grouping headers / footers.

  • Setting autoCommit to true automatically commits changes to records.

    Has a corresponding autoCommit config.

  • first : Model
    READONLY
    AjaxStore

    Get the first record locally available in the store.

  • Boolean flag, indicating whether the store has any data changes (its changes accessor returns a non-empty object). Cheaper than changes accessor itself, because it does not clone some internal data structures.

  • last : Model
    READONLY
    AjaxStore

    Get the last record locally available in the store.

  • Class used to represent records. Defaults to class EventModel.

    Has a corresponding modelClass config.

  • records : Model[]
    READONLY
    IMMUTABLE
    AjaxStore

    Returns all locally available "visible" records. Note: The returned value may not be mutated!

  • Yields the complete dataset size, ignoring filtering and grouping. If the store is paged, it returns the total value provided in the page load request response, or manually set.

  • An object containing key/value pairs that are passed on the request query string, or in the request body if HTTP method allows. See paramsInBody config.

    Has a corresponding params config.

  • Currently applied filters. A collection of CollectionFilter instances.

    Has a corresponding filters config.

  • Currently used groupers. To set groupers when remote sorting is enabled by sortParamName you should use setGroupers instead to be able to wait for the operation to finish.

    Has a corresponding groupers config.

  • Check if store is filtered

  • Is store currently grouped?

  • Is store sorted?

  • Currently applied sorters

    Has a corresponding sorters config.

  • Pretty printed version of json

  • groupHeaderRecords : Model[]
    READONLY
    NON-LAZY-LOAD
    StoreGroup

    Returns all the group header records

  • If the store is paged, yields the current page number.

  • sorterFn : Function
    internal
    READONLY
    StoreSort

    The sorter function for sorting records in the store.

  • true if this Store is configured to handle tree data (with tree : true) or if this is a chained store and the master store is a tree store.

  • Returns all leaf records in a tree store

  • The invisible root node of this tree.

Functions

Functions are methods available for calling on the class
  • onClassMixedIn( )
    internal
    static
    AjaxStore

    This optional class method is called when a class is mixed in using the mixin() method.

  • initClass( )
    static
    ADVANCED
    AjaxStore

    Registers this class type with its Factory

  • clear( )
    private
    StoreCRUD

    Clears store data. Used by removeAll, separate function for using with chained stores.

  • Reverts all changes in the store (adds removed records back, and removes newly added records).


    Triggers: change, refresh

  • Updates records available in a chained store by filtering the master store records using chainedFilterFn

  • In an EventStore or ResourceTimeRangeStore which is configured with lazyLoad, the function provided here is called when a combination of the visible date range and the visible range of resources has not yet been loaded. If the ResourceStore is not configured with lazyLoad, the resource range will include all the loaded resources. When implementing this, it is expected that what is returned is an object with a data property containing the records from startDate to endDate for a range of resources starting at startIndex and with the length specified in the count param.

    Base implementation does nothing, either use AjaxStore which implements it, or create your own subclass with an implementation.

    class MyEventStore extends EventStore {
       async requestData(params){
          const response = await fetch('https://api.bryntum.com/events/?' + new URLSearchParams(params));
          return await response.json();
       }
    }
    
  • Only available if the store is configured as lazyLoad.

    The records matching the provided parameters will be removed from the Store and reloaded the next they are needed.

    Provide an array of records or record ids, or provide a combination of resource records (or ids) and/or a date range. Do not combine the records params with the resources and startDate and endDate params.

  • Internal function used to hook destroy() calls when using thisObj

  • Internal function used restore hooked destroy() calls when using thisObj

  • doDestroy( )
    internal
    Events

    Auto detaches listeners registered from start, if set as detachable

  • once( )
    private
    Events

    Internal function used to run a callback function after an event is triggered

  • Removes all listeners registered to this object by the application.

  • Internal implementation for getEvents to use when not using dateMap.

  • Internal implementation for getEvents to use when using dateMap.

  • Resumes automatic commits upon store changes. Will trigger commit if the internal counter is 0.

  • Suspends automatic commits upon store changes. Can be called multiple times (it uses an internal counter).

  • Builds occurrences for the provided timespan across the provided date range.

  • Perform sorting according to the sorters configured. This is the internal implementation which is overridden in AjaxStore and must not be overridden.

  • Accepts all changes, resets the modification tracking:

    • Clears change tracking for all records
    • Clears added
    • Clears modified
    • Clears removed Leaves the store in an "unmodified" state.
  • Handles changes in master stores data. Updates the chained store accordingly

  • Handles refresh events from the master store. During batch operations, individual change events are suppressed and only a refresh event with action: 'batch' fires after endBatch(). This ensures the chained store stays in sync after batch operations.

  • Relays some function calls to the master store

  • Perform filtering according to the filters Collection. This is the internal implementation which is overridden in AjaxStore and must not be overridden.

  • Initialized relations, called from constructor

  • Updates relationCache for all records.

  • Sets a collection of related records. Will updated the related store and trigger events from it. Not to be called directly, called from Model setter.

  • Updates relation cache and foreign key value when a related objects id is changed.

Events

Events are triggered for certain actions in this class and can be listened for to react to those actions in your code
  • Fired when one of this Store's constituent records is modified while in batched state. This may be used to keep UIs up to date while "tentative" changes are made to a record which must not be synced with a server.

  • Fired when the store finished loading new chunks (the store stops loading). This event will not be triggered if the store has loading requests pending response.

  • Fired when the store starts loading new chunks (the store enters a state of loading). This event will not be triggered if new records are requested when the store already is loading.

Event handlers

Event handlers are callbacks called as a result of certain actions in this class
  • Called when one of this Store's constituent records is modified while in batched state. This may be used to keep UIs up to date while "tentative" changes are made to a record which must not be synced with a server.

  • Called when the store finished loading new chunks (the store stops loading). This event will not be called if the store has loading requests pending response.

  • Called when the store starts loading new chunks (the store enters a state of loading). This event will not be called if new records are requested when the store already is loading.