AbstractCrudManager

This is an abstract class serving as the base for the CrudManager class. It implements basic mechanisms to organize batch communication with a server. Yet it does not contain methods related to data transfer nor encoding. These methods are to be provided in sub-classes by consuming the appropriate mixins.

For example, this is how the class can be used to implement an JSON encoding system:

// let's make new CrudManager using AJAX as a transport system and JSON for encoding
class MyCrudManager extends JsonEncode(AjaxTransport(AbstractCrudManager)) {

}

Data transfer and encoding methods

These are methods that must be provided by subclasses of this class:

Configs

18

Common

Convenience shortcut to set only the url to load from, when you do not need to supply any other config options in the load section of the transport config.

Using loadUrl:

{
    loadUrl : 'read.php
}

Equals the following transport config:

{
    transport : {
        load : {
            url : 'read.php'
        }
    }
}

When read at runtime, it will return the value from transport.load.url.

Convenience shortcut to set only the url to sync to, when you do not need to supply any other config options in the sync section of the transport config.

Using loadUrl:

{
    syncUrl : 'sync.php
}

Equals the following transport config:

{
    transport : {
        load : {
            url : 'sync.php'
        }
    }
}

When read at runtime, it will return the value from transport.sync.url.

CRUD

Specify true to automatically call load method on the next frame after creation.

Called on the next frame to allow a Scheduler (or similar) linked to a standalone CrudManager to register its stores before loading starts.

true to automatically persist store changes after edits are made in any of the stores monitored. Please note that sync request will not be invoked immediately but only after autoSyncTimeout interval.

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

Sets the list of stores controlled by the CRUD manager.

When adding a store to the CrudManager, make sure the server response format is correct for load and sync requests. Learn more in the Working with data guide.

Store can be provided by itself, its id or as a store descriptor.

Specify as true to force sync requests to be sent when calling sync(), even if there are no local changes. Useful in a polling scenario, to keep client up to date with the backend.

Set to true to make STM ignore changes coming from the backend. This will allow user to only undo redo local changes.

Set to false to only include the id of a removed parent node in the request to the backend (also affects programmatic calls to get changes etc.), and not the ids of its children.

Consider the following scenario, removing parent 1:

{
  id : 1,
  children : [
    { id : 11 },
    { id : 12 }
  ]
}

With includeChildrenInRemoveRequest : false, the backend will only receive the removal of id 1.

With includeChildrenInRemoveRequest : true (the default), the backend will receive the removal of id 1, 11 and 12.

Field name to be used to transfer a phantom record identifier.

Field name to be used to transfer a phantom parent record identifier.

True to reset identifiers (defined by idField config) of phantom records before submitting them to the server.

Name of a store property to retrieve store identifiers from. Make sure you have an instance of a store to use it by id. Store identifier is used as a container name holding corresponding store data while transferring them to/from the server. By default, id property is used. And in case a container identifier has to differ this config can be used:

class CatStore extends Store {
    static configurable = {
        // store id is "meow" but for sending/receiving store data
        // we want to have "cats" container in JSON, so we create a new property "storeIdForCrud"
        id             : 'meow',
        storeIdForCrud : 'cats'
    }
});

// create an instance to use a store by id
new CatStore();

class MyCrudManager extends CrudManager {
    ...
    crudStores           : ['meow'],
    // crud manager will get store identifier from "storeIdForCrud" property
    storeIdProperty  : 'storeIdForCrud'
});

The storeIdProperty property can also be specified directly on a store:

class CatStore extends Store {
    static configurable = {
        // storeId is "meow" but for sending/receiving store data
        // we want to have "cats" container in JSON
        id              : 'meow',
        // so we create a new property "storeIdForCrud"..
        storeIdForCrud  : 'cats',
        // and point CrudManager to use it as the store identifier source
        storeIdProperty  : 'storeIdForCrud'
    }
});

class DogStore extends Store {
    static configurable = {
        // storeId is "dogs" and it will be used as a container name for the store data
        storeId : 'dogs',
        // id is set to get a store by identifier
        id      : 'dogs'
    }
});

// create an instance to use a store by id
new CatStore();
new DogStore();

class MyCrudManager extends CrudManager {
    ...
    crudStores : ['meow', 'dogs']
});

When true the Crud Manager does not require all updated and removed records to be mentioned in the sync response. In this case response should include only server side changes.

Please note that added records should still be mentioned in response to provide real identifier instead of the phantom one.

An array of store identifiers sets an alternative sync responses apply order. By default, the order in which sync responses are applied to the stores is the same as they registered in. But in case of some tricky dependencies between stores this order can be changed:

class MyCrudManager extends CrudManager {
    // register stores (will be loaded in this order: 'store1' then 'store2' and finally 'store3')
    crudStores : ['store1', 'store2', 'store3'],
    // but we apply changes from server to them in an opposite order
    syncApplySequence : ['store3', 'store2', 'store1']
});

When true forces the CRUD manager to process responses depending on their type attribute. So load request may be responded with sync response for example. Can be used for smart server logic allowing the server to decide when it's better to respond with a complete data set (load response) or it's enough to return just a delta (sync response).

true to write all fields from the record to the server. If set to false it will only send the fields that were modified. Note that any fields that have persist set to false will still be ignored and fields having alwaysWrite set to true will always be included.

Other

Sets the list of stores controlled by the CRUD manager.

When adding a store to the CrudManager, make sure the server response format is correct for load and sync requests. Learn more in the Working with data guide.

Store can be provided as in instance, using its id or as an CrudManagerStoreDescriptor object.

Properties

24

Common

Convenience shortcut to set only the url to load from, when you do not need to supply any other config options in the load section of the transport config.

Using loadUrl:

{
    loadUrl : 'read.php
}

Equals the following transport config:

{
    transport : {
        load : {
            url : 'read.php'
        }
    }
}

When read at runtime, it will return the value from transport.load.url.

Convenience shortcut to set only the url to sync to, when you do not need to supply any other config options in the sync section of the transport config.

Using loadUrl:

{
    syncUrl : 'sync.php
}

Equals the following transport config:

{
    transport : {
        load : {
            url : 'sync.php'
        }
    }
}

When read at runtime, it will return the value from transport.sync.url.

Class hierarchy

isAbstractCrudManager: Boolean= truereadonly
Identifies an object as an instance of AbstractCrudManager class, or subclass thereof.
isAbstractCrudManager: Boolean= truereadonlystatic
Identifies an object as an instance of AbstractCrudManager class, or subclass thereof.
Identifies an object as an instance of AbstractCrudManagerMixin class, or subclass thereof.
Identifies an object as an instance of AbstractCrudManagerMixin class, or subclass thereof.

CRUD

Returns current changes as an object consisting of added/modified/removed arrays of records for every managed store, keyed by each store's id. Returns null if no changes exist. Format:

{
    resources : {
        added    : [{ name : 'New guy' }],
        modified : [{ id : 2, name : 'Mike' }],
        removed  : [{ id : 3 }]
    },
    events : {
        modified : [{  id : 12, name : 'Cool task' }]
    },
    ...
}

The server revision stamp. The revision stamp is a number which should be incremented after each server-side change. This property reflects the current version of the data retrieved from the server and gets updated after each load and sync call.

A list of registered stores whose server communication will be collected into a single batch. Each store is represented by a store descriptor.

Specify as true to force sync requests to be sent when calling sync(), even if there are no local changes. Useful in a polling scenario, to keep client up to date with the backend.

Set to true to make STM ignore changes coming from the backend. This will allow user to only undo redo local changes.

Returns true if changes tracking is suspended

Returns true if the crud manager is currently loading data

Returns true if the crud manager is currently syncing data

isLoading: Booleanreadonly

Returns true if the crud manager is currently loading data

An array of stores presenting an alternative sync responses apply order. Each store is represented by a store descriptor.

Other

inlineData: Object

Get or set data of CrudManager stores. The returned data is identical to what toJSON returns:


const data = scheduler.crudManager.inlineData;

// data:
{
    events : [...],
    resources : [...],
    dependencies : [...],
    assignments : [...],
    timeRanges : [...],
    resourceTimeRanges : [...],
    ... other stores data
}


// Plug it back in later
scheduler.crudManager.inlineData = data;

The xxData properties are deprecated and will be removed in the future. Use xxinstead. For example eventsData is deprecated, use events instead. For now, both naming schemes are included in the data object

json: String

Get or set data of crudStores as a JSON string.

Get a JSON string:


const jsonString = scheduler.crudManager.json;

// returned jsonString:
'{"events":[...],"resources":[...],...}'

// object representation of the returned jsonString:
{
    resources    : [...],
    events       : [...],
    assignments  : [...],
    dependencies : [...],
    timeRanges   : [...],
    // data from other stores
}

Set a JSON string (to populate the CrudManager stores):

scheduler.crudManager.json = '{"events":[...],"resources":[...],...}'

The xxData properties are deprecated and will be removed in the future. Use xx instead. For example eventsData is deprecated, use events instead. For now, both naming schemes are included in the data object

revision: Numberreadonly

The server revision stamp. The revision stamp is a number which should be incremented after each server-side change. This property reflects the current version of the data retrieved from the server and gets updated after each load and sync call.

A list of registered stores whose server communication will be collected into a single batch. Each store is represented by a store descriptor.

Lifecycle

configBase

Functions

36

CRUD

Accepts all changes in all stores, resets the modification tracking:

  • Clears change tracking for all records
  • Clears added
  • Clears modified
  • Clears removed Leaves the store in an "unmodified" state.

Adds a store to the collection.

// append stores to the end of collection
crudManager.addCrudStore([
    store1,
    // storeId
    'bar',
    // store descriptor
    {
        storeId : 'foo',
        store   : store3
    },
    {
        storeId         : 'bar',
        store           : store4,
        // to write all fields of modified records
        writeAllFields  : true
    }
]);

Note: Order in which stores are kept in the collection is very essential sometimes. Exactly in this order the loaded data will be put into each store.

When adding a store to the CrudManager, make sure the server response format is correct for load and sync requests. Learn more in the Working with data guide.

ParameterTypeDescription
storeStore | String | CrudManagerStoreDescriptor | Store[] | String[] | CrudManagerStoreDescriptor[]

A store or list of stores. Each store might be specified by its instance, storeId or descriptor.

positionNumber

The relative position of the store. If fromStore is specified the position will be taken relative to it. If not specified then store(s) will be appended to the end of collection. Otherwise, it will be just a position in stores collection.

// insert stores store4, store5 to the start of collection
crudManager.addCrudStore([ store4, store5 ], 0);
fromStoreString | Store | CrudManagerStoreDescriptor

The store relative to which position should be calculated. Can be defined as a store identifier, instance or descriptor (the result of getStoreDescriptor call).

// insert store6 just before a store having storeId equal to 'foo'
crudManager.addCrudStore(store6, 0, 'foo');

// insert store7 just after store3 store
crudManager.addCrudStore(store7, 1, store3);

Adds a store to the alternative sync responses apply sequence. By default, the order in which sync responses are applied to the stores is the same as they registered in. But this order can be changes either on construction step using syncApplySequence option or by calling this method.

Please note, that if the sequence was not initialized before this method call then you will have to do it yourself like this for example:

// alternative sequence was not set for this crud manager
// so let's fill it with existing stores keeping the same order
crudManager.addStoreToApplySequence(crudManager.crudStores);

// and now we can add our new store

// we will load its data last
crudManager.addCrudStore(someNewStore);
// but changes to it will be applied first
crudManager.addStoreToApplySequence(someNewStore, 0);

add registered stores to the sequence along with the store(s) you want to add

ParameterTypeDescription
storeStore | CrudManagerStoreDescriptor | Store[] | CrudManagerStoreDescriptor[]

The store to add or its descriptor (or array of stores or descriptors).

positionNumber

The relative position of the store. If fromStore is specified the position will be taken relative to it. If not specified then store(s) will be appended to the end of collection. Otherwise, it will be just a position in stores collection.

// insert stores store4, store5 to the start of sequence
crudManager.addStoreToApplySequence([ store4, store5 ], 0);
fromStoreString | Store | CrudManagerStoreDescriptor

The store relative to which position should be calculated. Can be defined as a store identifier, instance or its descriptor (the result of getStoreDescriptor call).

// insert store6 just before a store having storeId equal to 'foo'
crudManager.addStoreToApplySequence(store6, 0, 'foo');

// insert store7 just after store3 store
crudManager.addStoreToApplySequence(store7, 1, store3);

Applies a set of changes, as an object keyed by store id, to the affected stores. This function is intended to use in apps that handle their own data syncing, it is not needed when using the CrudManager approach.

Example of a changeset:

project.applyChangeset({
    events : {
        added : [
            { id : 10, name : 'Event 10', startDate : '2022-06-07' }
        ],
        updated : [
            { id : 5, name : 'Changed' }
        ],
        removed : [
            { id : 1 }
        ]
    },
    resources : { ... },
    ...
});

Optionally accepts a transformFn to convert an incoming changeset to the expected format. See applyChangeset for more details.

Setting clearChanges param to false will result in restoring the changes on the store applied using the applyChangeset method. By default, it has been set to true to clear all the applied changes on the store.

For example, following will restore the changes on the store:

// Apply these changes using the applyChangeset method
project.applyChangeset({
    events : {
        added : [
            { id : 10, name : 'Event 10', startDate : '2022-06-07' }
        ],
        updated : [
            { id : 5, name : 'Changed' }
        ],
        removed : [
            { id : 1 }
        ]
    },
    resources : { ... },
    ...
}, null, '$PhantomId', false);
In SchedulerPro and Gantt, when autoSync is enabled, and client wants to apply changes without triggering a sync request, applyProjectChanges method should be used instead of this. It helps maintain current behavior while providing flexibility for scenarios where syncing is not required.
ParameterTypeDescription
changesObject

Changeset to apply, an object keyed by store id where each value follows the format described in applyChangeset

transformFnfunction

Optional function used to preprocess a changeset per store in a different format, should return an object with the format expected by applyChangeset

phantomIdFieldString

Field used by the backend when communicating a record being assigned a proper id instead of a phantom id

clearChangesBoolean

Set to false to not preserve the applied changes on the record

Returns true if any of registered stores (or some particular store) has non persisted changes.

// if we have any unsaved changes
if (crudManager.crudStoreHasChanges()) {
    // persist them
    crudManager.sync();
// otherwise
} else {
    alert("There are no unsaved changes...");
}
ParameterTypeDescription
storeIdString | Store

The store identifier or store instance to check changes for. If not specified then will check changes for all of the registered stores.

Returns: Boolean -

true if there are not persisted changes.

Returns a registered store.

ParameterTypeDescription
storeIdString

Store identifier.

Returns: Store -

Found store instance.

Returns a registered store descriptor.

ParameterTypeDescription
storeIdString | Store

The store identifier or registered store instance.

Returns: CrudManagerStoreDescriptor -

The descriptor of the store.

Loads data to the stores registered in the crud manager. For example:

crudManager.load(
    // here are request parameters
    {
        store1 : { append : true, page : 3, smth : 'foo' },
        store2 : { page : 2, bar : '!!!' }
    }
).then(
    () => alert('OMG! It works!'),
    ({ response, cancelled }) => console.log(`Error: ${cancelled ? 'Cancelled' : response.message}`)
);

** Note: ** If there is an incomplete load request in progress then system will try to cancel it by calling cancelRequest.

ParameterTypeDescription
optionsObject | String

The request parameters or a URL.

options.requestObject

An object which contains options to merge into the options which are passed to sendRequest.

{
    store1 : { page : 3, append : true, smth : 'foo' },
    store2 : { page : 2, bar : '!!!' },
    request : {
        params : {
            startDate : '2021-01-01'
        }
    }
},

Omitting request arg:

crudManager.load().then(
    () => alert('OMG! It works!'),
    ({ response, cancelled }) => console.log(`Error: ${cancelled ? 'Cancelled' : response.message}`)
);

When presented it should be an object where keys are store Ids and values are, in turn, objects of parameters related to the corresponding store. These parameters will be transferred in each store's entry in the stores property of the POST data.

Additionally, for flat stores append: true can be specified to add loaded records to the existing records, default is to remove corresponding store's existing records first. Please note that for delta loading you can also use an alternative approach.

options.request.typesync | load

The request type. Either load or sync.

options.request.urlString

The URL for the request. Overrides the URL defined in the transport object

options.request.dataString

The encoded Crud Manager request data.

options.request.paramsObject

An object specifying extra HTTP params to send with the request.

options.request.successfunction

A function to be started on successful request transferring.

options.request.success.rawResponseString

Response object returned by the fetch api.

options.request.failurefunction

A function to be started on request transfer failure.

options.request.failure.rawResponseString

Response object returned by the fetch api.

options.request.thisObjObject

this reference for the above success and failure functions.

Returns: Promise -

Promise, which is resolved if request was successful. Both the resolve and reject functions are passed a state object. State object has following structure:

{
    cancelled       : Boolean, // **optional** flag, which is present when promise was rejected
    rawResponse     : String,  // raw response from ajax request, either response xml or text
    rawResponseText : String,  // raw response text as String from ajax request
    response        : Object,  // processed response in form of object
    options         : Object   // options, passed to load request
}

If promise was rejected by beforeLoad event, state object will have the following structure:

{
    cancelled : true
}

Loads data to the Crud Manager

ParameterTypeDescription
responseObject

A simple object representing the data. The object structure matches the decoded load response structure:

// load static data into crudManager
crudManager.loadCrudManagerData({
    success   : true,
    resources : {
        rows : [
            { id : 1, name : 'John' },
            { id : 2, name : 'Abby' }
        ]
    }
});
optionsObject

Extra data loading options.

Removes a store from collection. If the store was registered in alternative sync sequence list it will be removed from there as well.

// remove store having storeId equal to "foo"
crudManager.removeCrudStore("foo");

// remove store3
crudManager.removeCrudStore(store3);
ParameterTypeDescription
storeCrudManagerStoreDescriptor | String | Store

The store to remove. Either the store descriptor, store identifier or store itself.

Removes a store from the alternative sync sequence.

// remove store having storeId equal to "foo"
crudManager.removeStoreFromApplySequence("foo");
ParameterTypeDescription
storeCrudManagerStoreDescriptor | String | Store

The store to remove. Either the store descriptor, store identifier or store itself.

Resumes automatic sync upon store changes. Will schedule a sync if the internal counter is 0.

ParameterTypeDescription
doSyncBoolean

Pass true to schedule a sync after resuming (if there are pending changes) and false to not persist the changes.

Resumes hasChanges and noChanges events. By default, it will check for changes and if there are any, hasChanges or noChanges event will be triggered.

ParameterTypeDescription
skipChangeCheckBoolean

Reverts all changes in all stores and re-inserts any records that were removed locally. Any new uncommitted records will be removed.

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

Persists changes made on the registered stores to the server and/or receives changes made on the backend. Usage:

// persist and run a callback on request completion
crud.sync().then(
    () => console.log("Changes saved..."),
    ({ response, cancelled }) => console.log(`Error: ${cancelled ? 'Cancelled' : response.message}`)
);

** Note: ** If there is an incomplete sync request in progress then system will queue the call and delay it until previous request completion. In this case syncDelayed event will be fired.

** Note: ** Please take a look at autoSync config. This option allows to persist changes automatically after any data modification.

** Note: ** By default a sync request is only sent if there are any local changes. To always send a request when calling this function, configure forceSync as true.

Returns: Promise -

Promise, which is resolved if request was successful. Both the resolve and reject functions are passed a state object. State object has the following structure:

{
    cancelled       : Boolean, // **optional** flag, which is present when promise was rejected
    rawResponse     : String,  // raw response from ajax request, either response xml or text
    rawResponseText : String,  // raw response text as String from ajax request
    response        : Object,  // processed response in form of object
}

If promise was rejected by the beforeSync event, state object will have this structure:

{
    cancelled : true
}

JSON

Returns the data from all CrudManager crudStores in a format that can be consumed by inlineData.

Used by JSON.stringify to correctly convert this CrudManager to json.

The returned data is identical to what inlineData contains.


const json = scheduler.crudManager.toJSON();

// json:
{
    events : [...],
    resources : [...],
    dependencies : [...],
    assignments : [...],
    timeRanges : [...],
    resourceTimeRanges : [...],
    // ... other stores data
}

Output can be consumed by inlineData.

const json = scheduler.crudManager.toJSON();

// Plug it back in later
scheduler.crudManager.inlineData = json;

The xxData properties are deprecated and will be removed in the future. Use xxinstead. For example eventsData is deprecated, use events instead. For now, both naming schemes are included in the data object

Returns: Object

Other

Adds a store to the collection.

// append stores to the end of collection
crudManager.addStore([
    store1,
    // store id
    'bar',
    // store descriptor
    {
        storeId : 'foo',
        store   : store3
    },
    {
        storeId         : 'bar',
        store           : store4,
        // to write all fields of modified records
        writeAllFields  : true
    }
]);

Note: Order in which stores are kept in the collection is very essential sometimes. Exactly in this order the loaded data will be put into each store.

When adding a store to the CrudManager, make sure the server response format is correct for load and sync requests. Learn more in the Working with data guide.

ParameterTypeDescription
storeStore | String | CrudManagerStoreDescriptor | Store[] | String[] | CrudManagerStoreDescriptor[]

A store or list of stores. Each store might be specified by its instance, storeId or descriptor.

positionNumber

The relative position of the store. If fromStore is specified the position will be taken relative to it. If not specified then store(s) will be appended to the end of collection. Otherwise, it will be an index in stores collection.

// insert stores store4, store5 to the start of collection
crudManager.addStore([ store4, store5 ], 0);
fromStoreString | Store | CrudManagerStoreDescriptor

The store relative to which position should be calculated. Can be defined as a store identifier, instance or descriptor (the result of getStoreDescriptor call).

// insert store6 just before a store having storeId equal to 'foo'
crudManager.addStore(store6, 0, 'foo');

// insert store7 just after store3 store
crudManager.addStore(store7, 1, store3);

Cancels request to the server.

ParameterTypeDescription
promisePromise

The request promise to cancel (a value returned by corresponding sendRequest call).

rejectfunction

Reject handle of the corresponding promise

Decodes response from the server.

ParameterTypeDescription
responseString

The response to decode.

Returns: Object -

The decoded response.

Encodes request to the server.

ParameterTypeDescription
requestObject

The request to encode.

Returns: String -

The encoded request.

Sends request to the server.

ParameterTypeDescription
requestObject

The request to send. An object having following properties:

request.typeload | sync

Request type, can be either load or sync

request.dataString

Encoded request.

request.successfunction

Callback to be started on successful request transferring

request.failurefunction

Callback to be started on request transfer failure

request.thisObjObject

this reference for the above success and failure callbacks

Returns: Promise -

The request promise.

Configuration

applyDefaultsstaticBase

Events

Lifecycle

destroystaticBase

Misc

initClassstaticBase
isOfTypeNamestaticBase
mixinstaticBase

Events

16

Fires before load request is sent. Return false to cancel load request.

// Adding a listener using the "on" method
abstractCrudManager.on('beforeLoad', ({ source, pack }) => {

});
ParameterTypeDescription
sourceAbstractCrudManager

The CRUD manager.

packObject

The data package which contains data for all stores managed by the crud manager.

Fires before loaded data get applied to the stores. Return false to prevent data applying. This event can be used for server data preprocessing. To achieve it user can modify the response object.

// Adding a listener using the "on" method
abstractCrudManager.on('beforeLoadApply', ({ source, response, options }) => {

});
ParameterTypeDescription
sourceAbstractCrudManager

The CRUD manager.

responseObject

The decoded server response object.

optionsObject

Options provided to the load method.

Fires before server response gets applied to the stores. Return false to prevent data applying. This event can be used for server data preprocessing. To achieve it user can modify the response object.

// Adding a listener using the "on" method
abstractCrudManager.on('beforeResponseApply', ({ source, requestType, response }) => {

});
ParameterTypeDescription
sourceAbstractCrudManager

The CRUD manager.

requestTypesync | load

The request type (sync or load).

responseObject

The decoded server response object.

Fires before sync request is sent. Return false to cancel sync request.

crudManager.on('beforesync', function() {
    // cannot persist changes before at least one record is added
    // to the `someStore` store
    if (!someStore.getCount()) return false;
});
// Adding a listener using the "on" method
abstractCrudManager.on('beforeSync', ({ source, pack }) => {

});
ParameterTypeDescription
sourceAbstractCrudManager

The CRUD manager.

packObject

The data package which contains data for all stores managed by the crud manager.

Fires before sync response data get applied to the stores. Return false to prevent data applying. This event can be used for server data preprocessing. To achieve it user can modify the response object.

// Adding a listener using the "on" method
abstractCrudManager.on('beforeSyncApply', ({ source, response }) => {

});
ParameterTypeDescription
sourceAbstractCrudManager

The CRUD manager.

responseObject

The decoded server response object.

Fires when data in any of the registered data stores is changed.

    crudManager.on('hasChanges', function (crud) {
        // enable persist changes button when some store gets changed
        saveButton.enable();
    });

You can suspend this event with suspendChangeTracking API call.

// Adding a listener using the "on" method
abstractCrudManager.on('hasChanges', ({ source }) => {

});
ParameterTypeDescription
sourceAbstractCrudManager

The CRUD manager.

Fires on successful load request completion after data gets loaded to the stores.

// Adding a listener using the "on" method
abstractCrudManager.on('load', ({ source, response, responseOptions, requestOptions, rawResponse }) => {

});
ParameterTypeDescription
sourceAbstractCrudManager

The CRUD manager.

responseObject

The decoded server response object.

responseOptionsObject

[DEPRECATED] see requestOptions

requestOptionsObject

The request options passed to the request.

rawResponseResponse

The native Response object

Fired after load request was canceled by some beforeLoad listener or due to incomplete prior load request.

// Adding a listener using the "on" method
abstractCrudManager.on('loadCanceled', ({ source, pack }) => {

});
ParameterTypeDescription
sourceAbstractCrudManager

The CRUD manager.

packObject

The data package which contains data for all stores managed by the crud manager.

Fires when a load request fails.

// Adding a listener using the "on" method
abstractCrudManager.on('loadFail', ({ source, response, responseText, responseOptions, requestOptions, rawResponse }) => {

});
ParameterTypeDescription
sourceAbstractCrudManager

The CRUD manager instance.

responseObject

The decoded server response object.

responseTextString

The raw server response text

responseOptionsObject

[DEPRECATED] see requestOptions

requestOptionsObject

The request options passed to the request.

rawResponseResponse

The native Response object

Fires when registered stores get into state when they don't have any not persisted change. This happens after load or sync request completion. Or this may happen after a record update which turns its fields back to their original state.

crudManager.on('nochanges', function (crud) {
    // disable persist changes button when there is no changes
    saveButton.disable();
});

You can suspend this event with suspendChangeTracking API call.

// Adding a listener using the "on" method
abstractCrudManager.on('noChanges', ({ source }) => {

});
ParameterTypeDescription
sourceAbstractCrudManager

The CRUD manager.

Fires on successful request completion after data gets applied to the stores.

// Adding a listener using the "on" method
abstractCrudManager.on('requestDone', ({ source, requestType, response, responseOptions, requestOptions, rawResponse }) => {

});
ParameterTypeDescription
sourceAbstractCrudManager

The CRUD manager.

requestTypesync | load

The request type (sync or load).

responseObject

The decoded server response object.

responseOptionsObject

[DEPRECATED] see requestOptions

requestOptionsObject

The request options passed to the request.

rawResponseResponse

The native Response object

Fires when a request fails.

// Adding a listener using the "on" method
abstractCrudManager.on('requestFail', ({ source, requestType, response, responseText, responseOptions, requestOptions, rawResponse }) => {

});
ParameterTypeDescription
sourceAbstractCrudManager

The CRUD manager instance.

requestTypesync | load

The request type (sync or load).

responseObject

The decoded server response object.

responseTextString

The raw server response text

responseOptionsObject

[DEPRECATED] see requestOptions

requestOptionsObject

The request options passed to the request.

rawResponseResponse

The native Response object

Fires on successful sync request completion.

// Adding a listener using the "on" method
abstractCrudManager.on('sync', ({ source, response, responseOptions, requestOptions, rawResponse }) => {

});
ParameterTypeDescription
sourceAbstractCrudManager

The CRUD manager.

responseObject

The decoded server response object.

responseOptionsObject

[DEPRECATED] see requestOptions

requestOptionsObject

The request options passed to the request.

rawResponseResponse

The native Response object

Fires after sync request was canceled by some beforeSync listener.

// Adding a listener using the "on" method
abstractCrudManager.on('syncCanceled', ({ source, pack }) => {

});
ParameterTypeDescription
sourceAbstractCrudManager

The CRUD manager.

packObject

The data package which contains data for all stores managed by the crud manager.

Fires after sync request was delayed due to incomplete previous one.

// Adding a listener using the "on" method
abstractCrudManager.on('syncDelayed', ({ source, arguments }) => {

});
ParameterTypeDescription
sourceAbstractCrudManager

The CRUD manager.

argumentsObject

The arguments of sync call.

Fires when a sync request fails.

// Adding a listener using the "on" method
abstractCrudManager.on('syncFail', ({ source, response, responseText, responseOptions, requestOptions, rawResponse }) => {

});
ParameterTypeDescription
sourceAbstractCrudManager

The CRUD manager instance.

responseObject

The decoded server response object.

responseTextString

The raw server response text

responseOptionsObject

[DEPRECATED] see requestOptions

requestOptionsObject

The request options passed to the request.

rawResponseResponse

The native Response object

Event handlers

16

Called before load request is sent. Return false to cancel load request.

new AbstractCrudManager({
    onBeforeLoad({ source, pack }) {

    }
});
ParameterTypeDescription
sourceAbstractCrudManager

The CRUD manager.

packObject

The data package which contains data for all stores managed by the crud manager.

Called before loaded data get applied to the stores. Return false to prevent data applying. This event can be used for server data preprocessing. To achieve it user can modify the response object.

new AbstractCrudManager({
    onBeforeLoadApply({ source, response, options }) {

    }
});
ParameterTypeDescription
sourceAbstractCrudManager

The CRUD manager.

responseObject

The decoded server response object.

optionsObject

Options provided to the load method.

Called before server response gets applied to the stores. Return false to prevent data applying. This event can be used for server data preprocessing. To achieve it user can modify the response object.

new AbstractCrudManager({
    onBeforeResponseApply({ source, requestType, response }) {

    }
});
ParameterTypeDescription
sourceAbstractCrudManager

The CRUD manager.

requestTypesync | load

The request type (sync or load).

responseObject

The decoded server response object.

Called before sync request is sent. Return false to cancel sync request.

crudManager.on('beforesync', function() {
    // cannot persist changes before at least one record is added
    // to the `someStore` store
    if (!someStore.getCount()) return false;
});
new AbstractCrudManager({
    onBeforeSync({ source, pack }) {

    }
});
ParameterTypeDescription
sourceAbstractCrudManager

The CRUD manager.

packObject

The data package which contains data for all stores managed by the crud manager.

Called before sync response data get applied to the stores. Return false to prevent data applying. This event can be used for server data preprocessing. To achieve it user can modify the response object.

new AbstractCrudManager({
    onBeforeSyncApply({ source, response }) {

    }
});
ParameterTypeDescription
sourceAbstractCrudManager

The CRUD manager.

responseObject

The decoded server response object.

Called when data in any of the registered data stores is changed.

    crudManager.on('hasChanges', function (crud) {
        // enable persist changes button when some store gets changed
        saveButton.enable();
    });

You can suspend this event with suspendChangeTracking API call.

new AbstractCrudManager({
    onHasChanges({ source }) {

    }
});
ParameterTypeDescription
sourceAbstractCrudManager

The CRUD manager.

Called on successful load request completion after data gets loaded to the stores.

new AbstractCrudManager({
    onLoad({ source, response, responseOptions, requestOptions, rawResponse }) {

    }
});
ParameterTypeDescription
sourceAbstractCrudManager

The CRUD manager.

responseObject

The decoded server response object.

responseOptionsObject

[DEPRECATED] see requestOptions

requestOptionsObject

The request options passed to the request.

rawResponseResponse

The native Response object

Called after load request was canceled by some beforeLoad listener or due to incomplete prior load request.

new AbstractCrudManager({
    onLoadCanceled({ source, pack }) {

    }
});
ParameterTypeDescription
sourceAbstractCrudManager

The CRUD manager.

packObject

The data package which contains data for all stores managed by the crud manager.

Called when a load request fails.

new AbstractCrudManager({
    onLoadFail({ source, response, responseText, responseOptions, requestOptions, rawResponse }) {

    }
});
ParameterTypeDescription
sourceAbstractCrudManager

The CRUD manager instance.

responseObject

The decoded server response object.

responseTextString

The raw server response text

responseOptionsObject

[DEPRECATED] see requestOptions

requestOptionsObject

The request options passed to the request.

rawResponseResponse

The native Response object

Called when registered stores get into state when they don't have any not persisted change. This happens after load or sync request completion. Or this may happen after a record update which turns its fields back to their original state.

crudManager.on('nochanges', function (crud) {
    // disable persist changes button when there is no changes
    saveButton.disable();
});

You can suspend this event with suspendChangeTracking API call.

new AbstractCrudManager({
    onNoChanges({ source }) {

    }
});
ParameterTypeDescription
sourceAbstractCrudManager

The CRUD manager.

Called on successful request completion after data gets applied to the stores.

new AbstractCrudManager({
    onRequestDone({ source, requestType, response, responseOptions, requestOptions, rawResponse }) {

    }
});
ParameterTypeDescription
sourceAbstractCrudManager

The CRUD manager.

requestTypesync | load

The request type (sync or load).

responseObject

The decoded server response object.

responseOptionsObject

[DEPRECATED] see requestOptions

requestOptionsObject

The request options passed to the request.

rawResponseResponse

The native Response object

Called when a request fails.

new AbstractCrudManager({
    onRequestFail({ source, requestType, response, responseText, responseOptions, requestOptions, rawResponse }) {

    }
});
ParameterTypeDescription
sourceAbstractCrudManager

The CRUD manager instance.

requestTypesync | load

The request type (sync or load).

responseObject

The decoded server response object.

responseTextString

The raw server response text

responseOptionsObject

[DEPRECATED] see requestOptions

requestOptionsObject

The request options passed to the request.

rawResponseResponse

The native Response object

Called on successful sync request completion.

new AbstractCrudManager({
    onSync({ source, response, responseOptions, requestOptions, rawResponse }) {

    }
});
ParameterTypeDescription
sourceAbstractCrudManager

The CRUD manager.

responseObject

The decoded server response object.

responseOptionsObject

[DEPRECATED] see requestOptions

requestOptionsObject

The request options passed to the request.

rawResponseResponse

The native Response object

Called after sync request was canceled by some beforeSync listener.

new AbstractCrudManager({
    onSyncCanceled({ source, pack }) {

    }
});
ParameterTypeDescription
sourceAbstractCrudManager

The CRUD manager.

packObject

The data package which contains data for all stores managed by the crud manager.

Called after sync request was delayed due to incomplete previous one.

new AbstractCrudManager({
    onSyncDelayed({ source, arguments }) {

    }
});
ParameterTypeDescription
sourceAbstractCrudManager

The CRUD manager.

argumentsObject

The arguments of sync call.

Called when a sync request fails.

new AbstractCrudManager({
    onSyncFail({ source, response, responseText, responseOptions, requestOptions, rawResponse }) {

    }
});
ParameterTypeDescription
sourceAbstractCrudManager

The CRUD manager instance.

responseObject

The decoded server response object.

responseTextString

The raw server response text

responseOptionsObject

[DEPRECATED] see requestOptions

requestOptionsObject

The request options passed to the request.

rawResponseResponse

The native Response object

Typedefs

1
ParameterTypeDescription
storeIdString

Unique store identifier. Store related requests/responses will be sent under this name.

storeStore

The store itself.

phantomIdFieldString

Set this if the store model has a predefined field to keep phantom record identifier.

idFieldString

id field name, if it's not specified then class will try to get it from store model.

writeAllFieldsBoolean

Set to true to write all fields from modified records