AbstractCrudManagerMixin
Configs
23
Configs
23Common
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
Properties
18
Properties
18Common
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
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' }]
},
...
}
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
An array of stores presenting an alternative sync responses apply order. Each store is represented by a store descriptor.
Misc
Other
Functions
32
Functions
32CRUD
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.
| Parameter | Type | Description |
|---|---|---|
store | Store | String | CrudManagerStoreDescriptor | Store[] | String[] | CrudManagerStoreDescriptor[] | A store or list of stores. Each store might be specified by its instance, |
position | Number | The relative position of the store. If |
fromStore | String | 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). |
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
| Parameter | Type | Description |
|---|---|---|
store | Store | CrudManagerStoreDescriptor | Store[] | CrudManagerStoreDescriptor[] | The store to add or its descriptor (or array of stores or descriptors). |
position | Number | The relative position of the store. If |
fromStore | String | 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). |
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);
| Parameter | Type | Description |
|---|---|---|
changes | Object | Changeset to apply, an object keyed by store id where each value follows the format described in applyChangeset |
transformFn | function | Optional function used to preprocess a changeset per store in a different format, should return an object with the format expected by applyChangeset |
phantomIdField | String | Field used by the backend when communicating a record being assigned a proper id instead of a phantom id |
clearChanges | Boolean | Set to |
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...");
}
| Parameter | Type | Description |
|---|---|---|
storeId | String | Store | The store identifier or store instance to check changes for. If not specified then will check changes for all of the registered stores. |
true if there are not persisted changes.
Returns a registered store.
| Parameter | Type | Description |
|---|---|---|
storeId | String | Store identifier. |
Found store instance.
Returns a registered store descriptor.
| Parameter | Type | Description |
|---|---|---|
storeId | String | Store | The store identifier or registered store instance. |
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.
| Parameter | Type | Description |
|---|---|---|
options | Object | String | The request parameters or a URL. |
options.request | Object | An object which contains options to merge into the options which are passed to sendRequest.
Omitting request arg:
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 Additionally, for flat stores |
options.request.type | sync | load | The request type. Either |
options.request.url | String | The URL for the request. Overrides the URL defined in the |
options.request.data | String | The encoded Crud Manager request data. |
options.request.params | Object | An object specifying extra HTTP params to send with the request. |
options.request.success | function | A function to be started on successful request transferring. |
options.request.success.rawResponse | String |
|
options.request.failure | function | A function to be started on request transfer failure. |
options.request.failure.rawResponse | String |
|
options.request.thisObj | Object |
|
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
| Parameter | Type | Description |
|---|---|---|
response | Object | A simple object representing the data.
The object structure matches the decoded |
options | Object | 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);
| Parameter | Type | Description |
|---|---|---|
store | CrudManagerStoreDescriptor | 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");
| Parameter | Type | Description |
|---|---|---|
store | CrudManagerStoreDescriptor | 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.
| Parameter | Type | Description |
|---|---|---|
doSync | Boolean | Pass |
Resumes hasChanges and noChanges events. By default, it will check for changes
and if there are any, hasChanges or noChanges event will be triggered.
| Parameter | Type | Description |
|---|---|---|
skipChangeCheck | Boolean |
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).
Suspends hasChanges and noChanges events.
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.
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
}
Other
Cancels request to the server.
| Parameter | Type | Description |
|---|---|---|
promise | Promise | The request promise to cancel (a value returned by corresponding sendRequest call). |
reject | function | Reject handle of the corresponding promise |
Decodes response from the server.
| Parameter | Type | Description |
|---|---|---|
response | String | The response to decode. |
The decoded response.
Encodes request to the server.
| Parameter | Type | Description |
|---|---|---|
request | Object | The request to encode. |
The encoded request.
Sends request to the server.
| Parameter | Type | Description |
|---|---|---|
request | Object | The request to send. An object having following properties: |
request.type | load | sync | Request type, can be either |
request.data | String | Encoded request. |
request.success | function | Callback to be started on successful request transferring |
request.failure | function | Callback to be started on request transfer failure |
request.thisObj | Object |
|
The request promise.
Events
19
Events
19Fires before load request is sent. Return false to cancel load request.
// Adding a listener using the "on" method
abstractCrudManagerMixin.on('beforeLoad', ({ source, pack }) => {
});| Parameter | Type | Description |
|---|---|---|
source | AbstractCrudManager | The CRUD manager. |
pack | Object | 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
abstractCrudManagerMixin.on('beforeLoadApply', ({ source, response, options }) => {
});| Parameter | Type | Description |
|---|---|---|
source | AbstractCrudManager | The CRUD manager. |
response | Object | The decoded server response object. |
options | Object | 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
abstractCrudManagerMixin.on('beforeResponseApply', ({ source, requestType, response }) => {
});| Parameter | Type | Description |
|---|---|---|
source | AbstractCrudManager | The CRUD manager. |
requestType | sync | load | The request type ( |
response | Object | 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
abstractCrudManagerMixin.on('beforeSync', ({ source, pack }) => {
});| Parameter | Type | Description |
|---|---|---|
source | AbstractCrudManager | The CRUD manager. |
pack | Object | 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
abstractCrudManagerMixin.on('beforeSyncApply', ({ source, response }) => {
});| Parameter | Type | Description |
|---|---|---|
source | AbstractCrudManager | The CRUD manager. |
response | Object | 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
abstractCrudManagerMixin.on('hasChanges', ({ source }) => {
});| Parameter | Type | Description |
|---|---|---|
source | AbstractCrudManager | The CRUD manager. |
Fires on successful load request completion after data gets loaded to the stores.
// Adding a listener using the "on" method
abstractCrudManagerMixin.on('load', ({ source, response, responseOptions, requestOptions, rawResponse }) => {
});| Parameter | Type | Description |
|---|---|---|
source | AbstractCrudManager | The CRUD manager. |
response | Object | The decoded server response object. |
responseOptions | Object | [DEPRECATED] see |
requestOptions | Object | The request options passed to the request. |
rawResponse | Response | 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
abstractCrudManagerMixin.on('loadCanceled', ({ source, pack }) => {
});| Parameter | Type | Description |
|---|---|---|
source | AbstractCrudManager | The CRUD manager. |
pack | Object | 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
abstractCrudManagerMixin.on('loadFail', ({ source, response, responseText, responseOptions, requestOptions, rawResponse }) => {
});| Parameter | Type | Description |
|---|---|---|
source | AbstractCrudManager | The CRUD manager instance. |
response | Object | The decoded server response object. |
responseText | String | The raw server response text |
responseOptions | Object | [DEPRECATED] see |
requestOptions | Object | The request options passed to the request. |
rawResponse | Response | 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
abstractCrudManagerMixin.on('noChanges', ({ source }) => {
});| Parameter | Type | Description |
|---|---|---|
source | AbstractCrudManager | The CRUD manager. |
Fires on successful request completion after data gets applied to the stores.
// Adding a listener using the "on" method
abstractCrudManagerMixin.on('requestDone', ({ source, requestType, response, responseOptions, requestOptions, rawResponse }) => {
});| Parameter | Type | Description |
|---|---|---|
source | AbstractCrudManager | The CRUD manager. |
requestType | sync | load | The request type ( |
response | Object | The decoded server response object. |
responseOptions | Object | [DEPRECATED] see |
requestOptions | Object | The request options passed to the request. |
rawResponse | Response | The native Response object |
Fires when a request fails.
// Adding a listener using the "on" method
abstractCrudManagerMixin.on('requestFail', ({ source, requestType, response, responseText, responseOptions, requestOptions, rawResponse }) => {
});| Parameter | Type | Description |
|---|---|---|
source | AbstractCrudManager | The CRUD manager instance. |
requestType | sync | load | The request type ( |
response | Object | The decoded server response object. |
responseText | String | The raw server response text |
responseOptions | Object | [DEPRECATED] see |
requestOptions | Object | The request options passed to the request. |
rawResponse | Response | The native Response object |
Fires on successful sync request completion.
// Adding a listener using the "on" method
abstractCrudManagerMixin.on('sync', ({ source, response, responseOptions, requestOptions, rawResponse }) => {
});| Parameter | Type | Description |
|---|---|---|
source | AbstractCrudManager | The CRUD manager. |
response | Object | The decoded server response object. |
responseOptions | Object | [DEPRECATED] see |
requestOptions | Object | The request options passed to the request. |
rawResponse | Response | The native Response object |
Fires after sync request was canceled by some beforeSync listener.
// Adding a listener using the "on" method
abstractCrudManagerMixin.on('syncCanceled', ({ source, pack }) => {
});| Parameter | Type | Description |
|---|---|---|
source | AbstractCrudManager | The CRUD manager. |
pack | Object | 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
abstractCrudManagerMixin.on('syncDelayed', ({ source, arguments }) => {
});| Parameter | Type | Description |
|---|---|---|
source | AbstractCrudManager | The CRUD manager. |
arguments | Object | The arguments of sync call. |
Fires when a sync request fails.
// Adding a listener using the "on" method
abstractCrudManagerMixin.on('syncFail', ({ source, response, responseText, responseOptions, requestOptions, rawResponse }) => {
});| Parameter | Type | Description |
|---|---|---|
source | AbstractCrudManager | The CRUD manager instance. |
response | Object | The decoded server response object. |
responseText | String | The raw server response text |
responseOptions | Object | [DEPRECATED] see |
requestOptions | Object | The request options passed to the request. |
rawResponse | Response | The native Response object |
Event handlers
19
Event handlers
19Called before load request is sent. Return false to cancel load request.
new AbstractCrudManagerMixin({
onBeforeLoad({ source, pack }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | AbstractCrudManager | The CRUD manager. |
pack | Object | 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 AbstractCrudManagerMixin({
onBeforeLoadApply({ source, response, options }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | AbstractCrudManager | The CRUD manager. |
response | Object | The decoded server response object. |
options | Object | 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 AbstractCrudManagerMixin({
onBeforeResponseApply({ source, requestType, response }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | AbstractCrudManager | The CRUD manager. |
requestType | sync | load | The request type ( |
response | Object | 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 AbstractCrudManagerMixin({
onBeforeSync({ source, pack }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | AbstractCrudManager | The CRUD manager. |
pack | Object | 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 AbstractCrudManagerMixin({
onBeforeSyncApply({ source, response }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | AbstractCrudManager | The CRUD manager. |
response | Object | 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 AbstractCrudManagerMixin({
onHasChanges({ source }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | AbstractCrudManager | The CRUD manager. |
Called on successful load request completion after data gets loaded to the stores.
new AbstractCrudManagerMixin({
onLoad({ source, response, responseOptions, requestOptions, rawResponse }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | AbstractCrudManager | The CRUD manager. |
response | Object | The decoded server response object. |
responseOptions | Object | [DEPRECATED] see |
requestOptions | Object | The request options passed to the request. |
rawResponse | Response | The native Response object |
Called after load request was canceled by some beforeLoad listener or due to incomplete prior load request.
new AbstractCrudManagerMixin({
onLoadCanceled({ source, pack }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | AbstractCrudManager | The CRUD manager. |
pack | Object | The data package which contains data for all stores managed by the crud manager. |
Called when a load request fails.
new AbstractCrudManagerMixin({
onLoadFail({ source, response, responseText, responseOptions, requestOptions, rawResponse }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | AbstractCrudManager | The CRUD manager instance. |
response | Object | The decoded server response object. |
responseText | String | The raw server response text |
responseOptions | Object | [DEPRECATED] see |
requestOptions | Object | The request options passed to the request. |
rawResponse | Response | 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 AbstractCrudManagerMixin({
onNoChanges({ source }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | AbstractCrudManager | The CRUD manager. |
Called on successful request completion after data gets applied to the stores.
new AbstractCrudManagerMixin({
onRequestDone({ source, requestType, response, responseOptions, requestOptions, rawResponse }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | AbstractCrudManager | The CRUD manager. |
requestType | sync | load | The request type ( |
response | Object | The decoded server response object. |
responseOptions | Object | [DEPRECATED] see |
requestOptions | Object | The request options passed to the request. |
rawResponse | Response | The native Response object |
Called when a request fails.
new AbstractCrudManagerMixin({
onRequestFail({ source, requestType, response, responseText, responseOptions, requestOptions, rawResponse }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | AbstractCrudManager | The CRUD manager instance. |
requestType | sync | load | The request type ( |
response | Object | The decoded server response object. |
responseText | String | The raw server response text |
responseOptions | Object | [DEPRECATED] see |
requestOptions | Object | The request options passed to the request. |
rawResponse | Response | The native Response object |
Called on successful sync request completion.
new AbstractCrudManagerMixin({
onSync({ source, response, responseOptions, requestOptions, rawResponse }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | AbstractCrudManager | The CRUD manager. |
response | Object | The decoded server response object. |
responseOptions | Object | [DEPRECATED] see |
requestOptions | Object | The request options passed to the request. |
rawResponse | Response | The native Response object |
Called after sync request was canceled by some beforeSync listener.
new AbstractCrudManagerMixin({
onSyncCanceled({ source, pack }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | AbstractCrudManager | The CRUD manager. |
pack | Object | 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 AbstractCrudManagerMixin({
onSyncDelayed({ source, arguments }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | AbstractCrudManager | The CRUD manager. |
arguments | Object | The arguments of sync call. |
Called when a sync request fails.
new AbstractCrudManagerMixin({
onSyncFail({ source, response, responseText, responseOptions, requestOptions, rawResponse }) {
}
});| Parameter | Type | Description |
|---|---|---|
source | AbstractCrudManager | The CRUD manager instance. |
response | Object | The decoded server response object. |
responseText | String | The raw server response text |
responseOptions | Object | [DEPRECATED] see |
requestOptions | Object | The request options passed to the request. |
rawResponse | Response | The native Response object |