AjaxStore

Store that uses the Fetch API to read data from a remote server, and optionally sends synchronization requests to the server containing information about locally created, modified and deleted records.

Create

Posts array of JSON data for newly added records to createUrl, expects response containing an array of JSON objects in same order with id set (uses Model#idField as id).

Read

Reads array of JSON data from the data packet returned from the readUrl. Unique id for each row is required.

By default looks in field 'id' but can be configured by setting idField.

Update

Posts array of JSON data containing modified records to updateUrl. By default, only changed fields and any fields configured with alwaysWrite are sent. If you want all fields to always be sent, please see writeAllFields

Delete

Posts to deleteUrl with removed records ids (for example id=1,4,7).

new AjaxStore({
  createUrl  : 'php/create',
  readUrl    : 'php/read',
  updateUrl  : 'php/update',
  deleteUrl  : 'php/delete',
  modelClass : Customer
});

Lazy loading

A store can be configured with lazyLoad set to true. This will make the store send a fetch request to the configured readUrl when a range of records is needed, rather than for the complete dataset at once. Each request will be made up of 1 chunk before and after the requested index (which gives a total of 2 chunks). The chunk size can be configured in the lazyLoad config.

There is a guide for implementing lazy loading in Grid.

Pagination

Configuring an AjaxStore with pageParamName or pageStartParamName means that the store requests pages of data from the remote source, sending the configured pageParamName or pageStartParamName to request the page along with the pageSizeParamName.

If pageParamName is set, that is passed with the requested page number (one based), along with the pageSizeParamName.

If pageStartParamName is set, that is passed with the requested page starting record index (zero based), along with the pageSizeParamName.

The JSON response packet for one page should look like this:

{
    "success" : true,
    "total"   : 50000,
    "data"    : [{
        "id"    : 1,
        "title" : "Row 1"
    }, ... for the rest of the pageSize ... ]
}

The success property indicates whether the request succeeded. If this is false, an exception event is fired.

The store needs to know the total dataset size in order to know how many pages it may ask for. This is returned in the total property

Remote filtering

To specify that filtering is the responsibility of the server, configure the store with filterParamName: 'nameOfFilterParameter'

When this is set, any filter operation causes the store to reload itself, encoding the filters as JSON representations in the filterParamName HTTP parameter.

The filters will look like this:

{
    "field": "country",
    "operator": "=",
    "value": "sweden",
    "caseSensitive": false
}

If the value of the filter is a date - it is serialized as a local time, using the format: YYYY-MM-DDThh:mm:ss.ms

The encoding may be overridden by configuring an implementation of encodeFilterParams into the store which returns the value for the filterParamName when passed an Iterable of filters.

Remote sorting

To specify that sorting is the responsibility of the server, configure the store with sortParamName: 'nameOfSortParameter'

When this is set, any sort operation causes the store to reload itself, encoding the sorters as JSON representations in the sortParamName HTTP parameter.

The sorters will look like this:

{
    "field": "name",
    "ascending": true
}

The encoding may be overridden by configuring an implementation of encodeSorterParams into the store which returns the value for the sortParamName when passed an Iterable of sorters.

Passing HTTP headers

As mentioned above AjaxStore uses the Fetch API under the hood. Specify fetchOptions and/or headers to have control over the options passed with all fetch calls. For example to pass along an authorization header:

const store = new AjaxStore({
   headers : {
       Authorization : 'auth-contents-goes-here'
   }
});

Learn more about the Fetch API over at MDN.

Getting local record count

To get the number of "visible" records locally available in the store (records that would be shown when using the Store as the data source for a Grid or similar), use the count property. This will return the number of records in the store after filtering and grouping has been applied, including the generated group headers and footers but excluding any records inside collapsed parents or group headers:

const visibleRecords = store.count;

To get other local counts, such as the total number of data records in the store including those collapsed away and filtered out (when not using remote filtering), use the more flexible getCount method:

// Include records that have been filtered out,
// as well as any records inside collapsed groups or tree nodes.
const records = store.getCount({
    collapsed   : true,
    filteredOut : true
});

// Including group headers + summary records
const records = store.getCount({
    headersFooters : true
});

// All records, including group headers and filtered out records
const allRecords = store.getCount({
    all : true
});

Configs

80

Common

autoCommitTimeout: Number= 10

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

autoLoad: Boolean

True to initiate a load when the store is instantiated

autoCommitStoreCRUD
dataStore
fieldsStore
groupersStoreGroup
idStore
listenersEvents
sortersStoreSort

CRUD

Url to post newly created records to.

The response must be in the form:

{
    "success": true,
    "data": [{
        "id": 0, "name": "General Motors"
    }, {
        "id": 1, "name": "Apple"
    }]
}

Just the array of data may be returned, however that precludes the orderly handling of errors encountered at the server.

If the server encountered an error, the packet would look like this:

{
    "success": false,
    "message": "Some kind of database error"
}

And that packet would be available in the exception handler in the response property of the event.

The success property may be omitted, it defaults to true.

Url for deleting records.

The response must be in the form:

{
    "success": true
}

If the server encountered an error, the packet would look like this:

{
    "success": false,
    "message": "Some kind of database error"
}

And that packet would be available in the exception handler in the response property of the event.

The success property may be omitted, it defaults to true.

Url to read data from.

The response must be in the form:

{
    "success": true,
    "data": [{
        "id": 0, "name": "General Motors"
    }, {
        "id": 1, "name": "Apple"
    }]
}

If the store is paged, the total dataset size must be returned in the responseTotalProperty property:

{
    "success": true,
    "data": [{
        "id": 0, "name": "General Motors"
    }, {
        "id": 1, "name": "Apple"
    }],
    "total": 65535
}

Just the array of data may be returned, however that precludes the orderly handling of errors encountered at the server.

If the server encountered an error, the packet would look like this:

{
    "success": false,
    "message": "Some kind of database error"
}

And that packet would be available in the exception handler in the response property of the event.

The success property may be omitted, it defaults to true.

Url to post record modifications to.

The response must be in the form:

{
    "success": true,
    "data": [{
        "id": 0, "name": "General Motors"
    }, {
        "id": 1, "name": "Apple"
    }]
}

Just the array of data may be returned, however that precludes the orderly handling of errors encountered at the server.

If the server encountered an error, the packet would look like this:

{
    "success": false,
    "message": "Some kind of database error"
}

And that packet would be available in the exception handler in the response property of the event.

The success property may be omitted, it defaults to true.

Other

This config is taken into account only when store is part of a scheduling project.

If such store loads data via readUrl, automatic calculation of the schedule after the load might lead to some data modifications (for example if syncDataOnLoad is enabled). Such modifications will then be submitted back to the server, which might not be needed, since the data is already coming from the server.

Enabling this config will ignore data modifications during the propagation stage and nothing will be submitted to server.

lazyLoad: Boolean | ObjectAlso a property

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, a request to the configured readUrl will be made.

LazyLoading is currently not supported in Calendar, Gantt, TaskBoard.

ParameterTypeDescription
lazyLoadObject

Lazy load config

lazyLoad.chunkSizeNumber

The number of records to be loaded before and after the requested index.

Pass a function to transform record creation data before it is sent to the backend

new AjaxStore({
     transformCreationData : payload => {
         // Transform the data and return the payload
         for (const creationData of payload.data) {
             creationData.timestamp = Date.now();
         }

         return payload;
     }
});
ParameterTypeDescription
payloadObject
payload.dataArray

The data that is going to be sent to the backend

Returns: Object -

Return the modified payload

Pass a function to transform data loaded from the backend before it is turned into records and added to the store

new AjaxStore({
     transformLoadedData : response => {
         // Transform the loaded data and return the response object
     }
});
ParameterTypeDescription
responseObject
response.dataArray

The data that is going to be loaded into the store

Returns: Object -

Returns the modified response object

Pass a function to transform records modification data before it is sent to the backend

new AjaxStore({
     transformModificationData : payload => {
         // Transform the data and return the payload
         for (const recordData of payload.data) {
             // Some kind of transformation here...
             if (recordData.ignore) {
                 ArrayHelper.remove(payload.data, recordData);
             }
         }

         return payload;
     }
});
ParameterTypeDescription
payloadObject
payload.dataArray

The data that is going to be sent to the backend

Returns: Object -

Return the modified payload

Pass a function to transform record removal data before it is sent to the backend

new AjaxStore({
     transformRemovalData : payload => {
         // Transform the data and return the payload
         const transformedData = {};
         for (const id of payload.ids) {
             transformedData[id] = true;
         }
         payload.ids = transformedData;

         return payload;
     }
});
ParameterTypeDescription
payloadObject
payload.idsArray

Ids for records being removed

Returns: Object -

Return the modified payload

useSparseIndexStoreSparseIndex

Remote

fetchOptions: Object

An object containing the Fetch options to pass to each server request issued by this store. Use this to control if credentials are sent and other options, read more at MDN.

Example usage:

const store = new AjaxStore({
   fetchOptions : {
       credentials : 'omit',
       redirect    : 'error'
   }
});
headers: Object<String, String>

A string keyed object containing the HTTP headers to add to each server request issued by this store.

AjaxStore uses the Fetch API under the hood, read more about headers on MDN

Example usage:

const store = new AjaxStore({
   headers : {
       Authorization : 'auth-contents-goes-here'
   }
});
httpMethods: HttpMethods= {"create":"POST","read":"GET","update":"PUT","delete":"DELETE"}

The HTTP methods to use for CRUD requests when useRestfulMethods is enabled.

new AjaxStore({
   useRestfulMethods : true,
   httpMethods : {
       create : 'POST',
       read   : 'POST',
       update : 'PATCH',
       delete : 'DELETE'
   }
});

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.

paramsInBody: Boolean= true

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.

parentIdParamName: String= id

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.

responseDataProperty: String= data

The property name in JSON responses from the server that contains the data for the records

{
  "success" : true,
  // The property name used here should match that of 'responseDataProperty'
  "data" : [
    ...
  ]
}
responseSuccessProperty: String= success

The optional property name in JSON responses from the server that contains a boolean success/fail status.

{
  "responseMeta" : {
  {
    "success" : true,
    "count" : 100
  },
  // The property name used here should match that of 'responseDataProperty'
  "data" : [
    ...
  ]
}

The store would be configured with:

 {
     ...
     successDataProperty : 'responseMeta.success',
     responseTotalProperty : 'responseMeta.count'
     ...
 }

responseTotalProperty: String= total

The property name in JSON responses from the server that contains the dataset total size when this store is paged or lazy loaded

{
  "success" : true,
  // The property name used here should match that of 'responseDataProperty'
  "data" : [
    ...
  ],
  // The property name used here should match that of 'responseTotalProperty'
  "total" : 65535
}
restfulFilter: Boolean

Set this flag to true if you are filtering remote using restful URLs (e.g. https://nominatim.openstreetmap.org/search/paris?format=json)

Note: When this is set, the filter string is appended to the readUrl.

sendAsFormData: Boolean= false

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

useRestfulMethods: Boolean= false

Set to ´true´ to use restful httpMethods

writeAllFields: Boolean= false

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

filterParamNameStoreFilter

Tree

Set to false to only include the id of a removed parent node in the request to the backend, and not the ids of its children. Applies when configured with a deleteUrl.

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.

treeStore

Advanced

stmStoreStm
storageStore
useLocaleSortStoreSort

Chained store

chainedFieldsStoreChained
chainedFilterFnStoreChained
chainFiltersStoreChained
dontRelayToMasterStoreChained
doRelayToMasterStoreChained
ignoreLinkRecordsStoreChained
masterStoreStoreChained
syncOrderStoreChained
syncSortStoreChained

Filtering

filtersStoreFilter
remoteFilterStoreFilter

Misc

Paging

pageParamNameStorePaging
pageSizeStorePaging
remotePagingStorePaging

Records

Sorting

remoteSortStoreSort
sortParamNameStoreSort

Properties

68

Common

idStore

Class hierarchy

isAjaxStore: Boolean= truereadonly
Identifies an object as an instance of AjaxStore class, or subclass thereof.
isAjaxStore: Boolean= truereadonlystatic
Identifies an object as an instance of AjaxStore class, or subclass thereof.
isEventsEvents
isStoreStore
isStoreChainedStoreChained
isStoreChangesStoreChanges
isStoreCRUDStoreCRUD
isStoreFilterStoreFilter
isStoreGroupStoreGroup
isStorePagingStorePaging
isStoreRelationStoreRelation
isStoreSearchStoreSearch
isStoreSortStoreSort
isStoreSparseIndexStoreSparseIndex
isStoreStateStoreState
isStoreStmStoreStm
isStoreSumStoreSum
isStoreSyncStoreSync
isStoreTreeStoreTree

CRUD

Url to post newly created records to.

The response must be in the form:

{
    "success": true,
    "data": [{
        "id": 0, "name": "General Motors"
    }, {
        "id": 1, "name": "Apple"
    }]
}

Just the array of data may be returned, however that precludes the orderly handling of errors encountered at the server.

If the server encountered an error, the packet would look like this:

{
    "success": false,
    "message": "Some kind of database error"
}

And that packet would be available in the exception handler in the response property of the event.

The success property may be omitted, it defaults to true.

Url for deleting records.

The response must be in the form:

{
    "success": true
}

If the server encountered an error, the packet would look like this:

{
    "success": false,
    "message": "Some kind of database error"
}

And that packet would be available in the exception handler in the response property of the event.

The success property may be omitted, it defaults to true.

isCommitting: Booleanreadonly

Returns true if the Store is currently committing

isLoading: Boolean | Numberreadonly

Returns a truthy value if the Store is currently loading.

A load operation is initiated by a load call, but the network request is not sent until after a delay until the next event loop because of allowing all operations which may request a load to coalesce into one call.

If the loading request is in this waiting state, the value will be 1,

If the network request is in flight, the value will be 2

Url to read data from.

The response must be in the form:

{
    "success": true,
    "data": [{
        "id": 0, "name": "General Motors"
    }, {
        "id": 1, "name": "Apple"
    }]
}

If the store is paged, the total dataset size must be returned in the responseTotalProperty property:

{
    "success": true,
    "data": [{
        "id": 0, "name": "General Motors"
    }, {
        "id": 1, "name": "Apple"
    }],
    "total": 65535
}

Just the array of data may be returned, however that precludes the orderly handling of errors encountered at the server.

If the server encountered an error, the packet would look like this:

{
    "success": false,
    "message": "Some kind of database error"
}

And that packet would be available in the exception handler in the response property of the event.

The success property may be omitted, it defaults to true.

Url to post record modifications to.

The response must be in the form:

{
    "success": true,
    "data": [{
        "id": 0, "name": "General Motors"
    }, {
        "id": 1, "name": "Apple"
    }]
}

Just the array of data may be returned, however that precludes the orderly handling of errors encountered at the server.

If the server encountered an error, the packet would look like this:

{
    "success": false,
    "message": "Some kind of database error"
}

And that packet would be available in the exception handler in the response property of the event.

The success property may be omitted, it defaults to true.

Other

lazyLoad: Boolean | ObjectAlso a config

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, a request to the configured readUrl will be made.

LazyLoading is currently not supported in Calendar, Gantt, TaskBoard.

ParameterTypeDescription
lazyLoadObject

Lazy load config

lazyLoad.chunkSizeNumber

The number of records to be loaded before and after the requested index.

currentPageStorePaging
jsonStore
storesstaticStore

Remote

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.

Advanced

isChainedStoreChained
StopBranchstaticStoreTree

Filtering

Lifecycle

configBase

Misc

Paging

isPagedStorePaging
lastPageStorePaging
pageSizeStorePaging

Records

autoCommitStoreCRUD
changesStoreCRUD
countStore
dataStore
firstStore
hasChangesStoreCRUD
lastStore
recordsStore

Sort, group & filter

filtersStoreFilter
groupersStoreGroup
isFilteredStoreFilter
isGroupedStoreGroup
isSortedStoreSort
sortersStoreSort

Tree

isTreeStoreTree
leavesStoreTree

Functions

101

CRUD

Commits all changes (added, modified and removed) using corresponding urls (createUrl, updateUrl and deleteUrl)

Returns: Promise | Boolean -

A Promise which is resolved only if all pending changes (Create, Update and Delete) successfully resolve. Both the resolve and reject functions are passed a commitState object which is stored the afterRequest event for each request. Each event contains the exception, request and response properties eg:

{
     // If *all* commits succeeded
     success: true,
     changes: {
         added: [records...],
         modified: [records...],
         removed: [records...],
     },
     added: {
         source: theStore,

         // Only if the add request triggered an exception
         exception: true,

         // Only if the add request triggered an exception
         exceptionType: 'server', // Or 'network'

         response: Response,
         json: parsedResponseObject
     },
     // Same format as added
     modified: {},
     removed: {}
}

If there were no pending changes, the resolve and reject functions are passed no parameters.

If a commit operation already is in progress, a new one will be queued to execute after. The resolved function is passed the event object passed to any event handlers. The rejected function is passed the exception event if an exception occurred.

Load data from the readUrl. If configured as lazyLoad, this will load 1 chunk of records starting from index 0. If the store has previously been loaded, it will first be cleared of all records and all lazy load cache.

ParameterTypeDescription
paramsObject

A hash of parameters to append to querystring (will also append Store#params)

Returns: Promise -

A Promise which will be resolved if the load succeeds, and rejected if the load is vetoed by a beforeLoad handler, or if an exception is detected. The resolved function is passed the event object passed to any event handlers. The rejected function is passed the exception event if an exception occurred, or false if the load was vetoed by a beforeLoad handler.

Loads children into specified parent record. Parent records id is sent as a param (param name configured with parentIdParamName.

ParameterTypeDescription
parentRecordModel

Parent record

Returns: Promise -

A Promise which will be resolved if the load succeeds, and rejected if the load is vetoed by a beforeLoadChildren handler, or if an exception is detected. The resolved function is passed the event object passed to any event handlers. The rejected function is passed the exception event if an exception occurred, or false if the load was vetoed by a beforeLoadChildren handler.

Loads a page of data from the readUrl.

ParameterTypeDescription
pageNumber

The one based page number to load.

paramsObject

A hash of parameters to append to querystring (will also append Store#params)

Returns: Promise -

A Promise which will be resolved if the load succeeds, and rejected if the load is vetoed by a beforeLoadPage handler, or if an exception is detected. The resolved function is passed the event object passed to any event handlers. The rejected function is passed the exception event if an exception occurred, or false if the load was vetoed by a beforeLoadPage handler.

addStoreCRUD
applyChangesetStoreChanges
insertStoreCRUD
moveStoreCRUD
nextPageStorePaging
previousPageStorePaging
removeStoreCRUD
removeAllStoreCRUD
revertChangesStoreCRUD

Other

A provided function which creates an array of values for the filterParamName to pass any filters to the server upon load.

By default, this creates a JSON string containing the following properties:

   [{
       field         : <theFieldName>
       operator      : May be: `'='`, `'!='`, `'>'`, `'>='`, `'<'`, `'<='`, `'*'`, `'startsWith'`, `'endsWith'`
       value         : The value to compare
       caseSensitive : true for case sensitive comparisons
   }]
ParameterTypeDescription
filtersCollectionFilter[]

The filters to encode.

A provided function which creates an array of values for the {#config-sortParamName} to pass any sorters to the server upon load.

By default, this creates a JSON string containing the following properties:

   [{
       field     : <theFieldName>
       ascending : true/false
   }]
ParameterTypeDescription
sortersSorter[]

The sorters to encode.

getStorestaticStore
onEvents
relayAllEvents
toJSONStore
triggerEvents
unEvents

Chained store

chainStoreChained
chainTreeStoreChained
fillFromMasterStoreChained

Configuration

applyDefaultsstaticBase

Events

Iteration

everyStore
flatMapStore
forEachStore
mapStore
reduceStore

Lifecycle

destroystaticBase

Misc

initClassstaticBase
isOfTypeNamestaticBase
mixinstaticBase

Records

getAtStore
getByIdStore
indexOfStore

Search

findStoreSearch
findByFieldStoreSearch
findRecordStoreSearch
queryStoreSearch
searchStoreSearch
someStoreSearch

Sort, group & filter

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

Sum

averageStoreSum
groupSumStoreSum
maxStoreSum
minStoreSum
sumStoreSum

Traverse

getNextStore
getPrevStore

Tree

getChildrenStoreTree
indentStoreTree
outdentStoreTree

Values

Events

45

Fired before loading starts. Allows altering parameters and is cancelable by returning false. For paged stores, instead listen to beforeLoadPage. For remote loading of tree child nodes, listen to beforeLoadChildren.

// Adding a listener using the "on" method
ajaxStore.on('beforeLoad', ({ source, action, url, params }) => {

});
ParameterTypeDescription
sourceStore

This Store

actionString

The read action being performed: 'read'

urlString

The URL to which the HTTP request will be sent. This property may be mutated in an event handler without changing the base readUrl configured for this Store.

paramsObject

An object containing property/name pairs which are the parameters. This may be mutated to affect the parameters used in the Ajax request.

Fired before loading of remote child nodes of a tree node starts. Allows altering parameters and is cancelable

// Adding a listener using the "on" method
ajaxStore.on('beforeLoadChildren', ({ source, action, url, params }) => {

});
ParameterTypeDescription
sourceStore

This Store

actionString

The read action being performed: 'readChildren'

urlString

The URL to which the HTTP request will be sent. This property may be mutated in an event handler without changing the base readUrl configured for this Store.

paramsObject

An object containing property/name pairs which are the parameters. This may be mutated to affect the parameters used in the Ajax request.

Fired after committing added records

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

});
ParameterTypeDescription
sourceStore

This Store

Fired after committing modified records

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

});
ParameterTypeDescription
sourceStore

This Store

Fired after committing removed records

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

});
ParameterTypeDescription
sourceStore

This Store

Fired when a remote request fails, either at the network level, or the server returns a failure, or an invalid response.

Note that when a commit fails, more than one exception event will be triggered. The individual operation, create, update or delete will trigger their own exception event, but the encapsulating commit operation will also trigger an exception event when all the operations have finished, so if exceptions are going to be handled gracefully, the event's action property must be examined, and the constituent operations of the event must be examined.

// Adding a listener using the "on" method
ajaxStore.on('exception', ({ source, exception, action, exceptionType, response, json }) => {

});
ParameterTypeDescription
sourceStore

This Store

exceptionBoolean

true

actioncreate | read | update | delete | commit

Action that failed, 'create', 'read', 'update' or 'delete'. May also be fired with 'commit' to indicate the failure of an aggregated create, update and delete operation. In this case, the event will contain a property for each operation of the commit named 'create', 'update' and 'delete', each containing the individual exception events.

exceptionTypenetwork | failure

The type of failure, 'network' or 'server'

responseResponse

the Response object

jsonObject

The decoded response object if the exceptionType is 'server'

Fired on successful load

// Adding a listener using the "on" method
ajaxStore.on('load', ({ source, data, response, json }) => {

});
ParameterTypeDescription
sourceStore

This Store

dataObject[]

Data loaded

responseResponse

the Response object

jsonObject

The decoded response object.

Fired on successful load of remote child nodes for a tree node.

// Adding a listener using the "on" method
ajaxStore.on('loadChildren', ({ source, data, json }) => {

});
ParameterTypeDescription
sourceStore

This Store

dataObject[]

Data loaded

jsonObject

The decoded response object.

Fired when loading of remote child nodes into a tree node is beginning. This is not cancelable. Parameters in the event may still be mutated at this stage.

// Adding a listener using the "on" method
ajaxStore.on('loadChildrenStart', ({ source, params }) => {

});
ParameterTypeDescription
sourceStore

This Store

paramsObject

An object containing property/name pairs which are the parameters. This may be mutated to affect the parameters used in the Ajax request.

When the store is paged, this is fired when a page load is beginning.

// Adding a listener using the "on" method
ajaxStore.on('loadPageStart', ({ source, params }) => {

});
ParameterTypeDescription
sourceStore

This Store

paramsObject

An object containing property/name pairs which are the parameters. This may be mutated to affect the parameters used in the Ajax request.

Fired when loading is beginning. This is not cancelable. Parameters in the event may still be mutated at this stage.

// Adding a listener using the "on" method
ajaxStore.on('loadStart', ({ source, params }) => {

});
ParameterTypeDescription
sourceStore

This Store

paramsObject

An object containing property/name pairs which are the parameters. This may be mutated to affect the parameters used in the Ajax request.

addStoreCRUD
beforeAddStoreCRUD
beforeCommitStoreCRUD
beforeFilterStoreFilter
beforeIndentStoreTree
beforeLoadPageStorePaging
beforeOutdentStoreTree
beforeRemoveStoreCRUD
beforeSortStoreSort
catchAllEvents
changeStore
commitStoreCRUD
destroyEvents
filterStoreFilter
groupStoreGroup
indentStoreTree
loadPageStorePaging
moveStore
outdentStoreTree
refreshStore
removeStoreCRUD
removeAllStoreCRUD
sortStoreSort
updateStore

Event handlers

45

Called before loading starts. Allows altering parameters and is cancelable by returning false. For paged stores, instead listen to beforeLoadPage. For remote loading of tree child nodes, listen to beforeLoadChildren.

new AjaxStore({
    onBeforeLoad({ source, action, url, params }) {

    }
});
ParameterTypeDescription
sourceStore

This Store

actionString

The read action being performed: 'read'

urlString

The URL to which the HTTP request will be sent. This property may be mutated in an event handler without changing the base readUrl configured for this Store.

paramsObject

An object containing property/name pairs which are the parameters. This may be mutated to affect the parameters used in the Ajax request.

Called before loading of remote child nodes of a tree node starts. Allows altering parameters and is cancelable

new AjaxStore({
    onBeforeLoadChildren({ source, action, url, params }) {

    }
});
ParameterTypeDescription
sourceStore

This Store

actionString

The read action being performed: 'readChildren'

urlString

The URL to which the HTTP request will be sent. This property may be mutated in an event handler without changing the base readUrl configured for this Store.

paramsObject

An object containing property/name pairs which are the parameters. This may be mutated to affect the parameters used in the Ajax request.

Called after committing added records

new AjaxStore({
    onCommitAdded({ source }) {

    }
});
ParameterTypeDescription
sourceStore

This Store

Called after committing modified records

new AjaxStore({
    onCommitModified({ source }) {

    }
});
ParameterTypeDescription
sourceStore

This Store

Called after committing removed records

new AjaxStore({
    onCommitRemoved({ source }) {

    }
});
ParameterTypeDescription
sourceStore

This Store

Called when a remote request fails, either at the network level, or the server returns a failure, or an invalid response.

Note that when a commit fails, more than one exception event will be called. The individual operation, create, update or delete will trigger their own exception event, but the encapsulating commit operation will also trigger an exception event when all the operations have finished, so if exceptions are going to be handled gracefully, the event's action property must be examined, and the constituent operations of the event must be examined.

new AjaxStore({
    onException({ source, exception, action, exceptionType, response, json }) {

    }
});
ParameterTypeDescription
sourceStore

This Store

exceptionBoolean

true

actioncreate | read | update | delete | commit

Action that failed, 'create', 'read', 'update' or 'delete'. May also be fired with 'commit' to indicate the failure of an aggregated create, update and delete operation. In this case, the event will contain a property for each operation of the commit named 'create', 'update' and 'delete', each containing the individual exception events.

exceptionTypenetwork | failure

The type of failure, 'network' or 'server'

responseResponse

the Response object

jsonObject

The decoded response object if the exceptionType is 'server'

Called on successful load

new AjaxStore({
    onLoad({ source, data, response, json }) {

    }
});
ParameterTypeDescription
sourceStore

This Store

dataObject[]

Data loaded

responseResponse

the Response object

jsonObject

The decoded response object.

Called on successful load of remote child nodes for a tree node.

new AjaxStore({
    onLoadChildren({ source, data, json }) {

    }
});
ParameterTypeDescription
sourceStore

This Store

dataObject[]

Data loaded

jsonObject

The decoded response object.

Called when loading of remote child nodes into a tree node is beginning. This is not cancelable. Parameters in the event may still be mutated at this stage.

new AjaxStore({
    onLoadChildrenStart({ source, params }) {

    }
});
ParameterTypeDescription
sourceStore

This Store

paramsObject

An object containing property/name pairs which are the parameters. This may be mutated to affect the parameters used in the Ajax request.

When the store is paged, this is called when a page load is beginning.

new AjaxStore({
    onLoadPageStart({ source, params }) {

    }
});
ParameterTypeDescription
sourceStore

This Store

paramsObject

An object containing property/name pairs which are the parameters. This may be mutated to affect the parameters used in the Ajax request.

Called when loading is beginning. This is not cancelable. Parameters in the event may still be mutated at this stage.

new AjaxStore({
    onLoadStart({ source, params }) {

    }
});
ParameterTypeDescription
sourceStore

This Store

paramsObject

An object containing property/name pairs which are the parameters. This may be mutated to affect the parameters used in the Ajax request.

onAddStoreCRUD
onBeforeAddStoreCRUD
onBeforeFilterStoreFilter
onBeforeLoadPageStorePaging
onBeforeSortStoreSort
onCommitStoreCRUD
onDestroyEvents
onFilterStoreFilter
onGroupStoreGroup
onIndentStoreTree
onLoadPageStorePaging
onMoveStore
onOutdentStoreTree
onRemoveStoreCRUD
onRemoveAllStoreCRUD
onSortStoreSort

Typedefs

9

Http methods used by the AjaxStore in restful mode.

ParameterTypeDescription
createPOST | PUT
readGET | POST
updatePATCH | POST | PUT
deleteDELETE | POST
GrouperStoreGroup
SorterStoreSort