CustomStore

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

Included in: dx.phonejs.js, dx.webappjs.js, dx.chartjs.js, dx.all.js
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(values) {
        // . . .
    },
    . . .  
});

Note that despite Store operations being asynchronous and returning the jQuery.Deferred promise, you do not need to create the jQuery.Deferred object within your function. The function should return an object compatible with jQuery.Deferred.

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

Configuration

This section describes configuration options used to configure the CustomStore.

Name Description
byKey

The user implementation of the byKey(key, extraOptions) method.

errorHandler

Specifies the function called when the Store causes an error.

insert

The user implementation of the insert(values) method.

key

Specifies the key properties within the data associated with the Store.

load

The user implementation of the load(options) method.

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

The user implementation of the remove(key) method.

totalCount

The user implementation of the totalCount(options) method.

update

The user implementation of the update(key, values) method.

Methods

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

Name Description
byKey(key)

Returns the data item specified by the key.

insert(values)

Adds an item to the data associated with this Store.

key()

Returns the key expression specified via the key configuration option.

keyOf(obj)

Returns the key of the Store item that matches the specified object.

load(options)

Starts loading data.

off(eventName)

Detaches all event handlers from the specified event.

off(eventName, eventHandler)

Detaches a particular event handler from the specified event.

on(eventName, eventHandler)

Subscribes to a specified event.

on(events)

Subscribes to the specified events.

remove(key)

Removes the data item specified by the key.

totalCount(options)

Obtains the total count of items that will be returned by the load() function.

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.