CustomStore

A Store object that enables you to implement your own data access logic.

Included in: dx.mobile.js, dx.web.js, dx.viz.js, dx.viz-web.js, dx.all.js
Export: default
Type:

Object

This class requires you to implement all data access operations. Each function implementing an operation should be passed to the corresponding configuration option of the CustomStore.

JavaScript
var store = new DevExpress.data.CustomStore({
    load: function(loadOptions) {
        // . . .
    },
    byKey: function(key, extra) {
        // . . .
    },
    update: function(key, values) {
        // . . .
    },
    . . .  
});

For more information on creating a CustomStore, refer to the Data Source Examples topic.

Configuration

This section describes options that configure the CustomStore.

Name Description
byKey

Specifies a custom implementation of the byKey(key) method.

cacheRawData

Specifies whether raw data should be saved in the cache. Applies only if loadMode is "raw".

errorHandler

Specifies the function called when the Store causes an error.

insert

Specifies a custom implementation of the insert(values) method.

key

Specifies the key property or properties.

load

Specifies a custom implementation of the load(options) method.

loadMode

Specifies how data returned by the load function is treated.

onInserted

A handler for the inserted event.

onInserting

A handler for the inserting event.

onLoaded

A handler for the loaded event.

onLoading

A handler for the loading event.

onModified

A handler for the modified event.

onModifying

A handler for the modifying event.

onRemoved

A handler for the removed event.

onRemoving

A handler for the removing event.

onUpdated

A handler for the updated event.

onUpdating

A handler for the updating event.

remove

Specifies a custom implementation of the remove(key) method.

totalCount

Specifies a custom implementation of the totalCount(options) method.

update

Specifies a custom implementation of the update(key, values) method.

useDefaultSearch

Specifies whether the store combines the search and filter expressions. Defaults to true if the loadMode is "raw" and false if it is "processed".

Methods

This section describes the methods used to access data associated with the CustomStore.

Name Description
byKey(key)

Gets a data item with a specific key.

clearRawDataCache()

Deletes data from the cache. Takes effect only if the cacheRawData option is true.

insert(values)

Adds an item to the Store's data.

key()

Gets the key option's value.

keyOf(obj)

Gets the key value of an item found using its data object.

load()

Starts loading data.

load(options)

Starts loading data.

off(eventName)

Detaches all event handlers from a single event.

off(eventName, eventHandler)

Detaches a particular event handler from a single event.

on(eventName, eventHandler)

Subscribes to an event.

on(events)

Subscribes to events.

remove(key)

Removes a data item with a specific key.

totalCount(options)

Gets the total count of items the load() function returns.

update(key, values)

Updates the data item specified by the key.

Events

This section describes events raised by this Data Store object.

Name Description
inserted

Fires after a data item is added.

inserting

Fires before a data item is added.

loaded

Fires after data is loaded.

loading

Fires before data is loaded.

modified

Fires after data is modified.

modifying

Fires before the data is modified.

removed

Fires after a data item has been removed.

removing

Fires before a data item is removed.

updated

Fires after a data item has been updated.

updating

Fires before a data item is updated.

To handle events, use one of the following methods.

LoadOptions

This section describes the loadOptions object's fields.

Type:

Object

This object is used to specify settings according to which the server should process data. More often these settings are passed as a parameter to the load function and depend on the operations (paging, filtering, sorting, etc.) that you have enabled in the DataSource or widget.

See Also