LocalStore

A Store providing access to the HTML5 Web Storage.

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

Object

When creating a LocalStore instance, specify the name configuration option, which is required to identify the data within the storage.

JavaScript
var store = new DevExpress.data.LocalStore({
    name: "MyLocalData",
    key: "id"
});

Note that the key option is required if you are going to use the Store for read-write access to data.

For more information on working with LocalStore data, refer to the Data Source Examples article.

Configuration

This section describes configuration options used to configure the LocalStore.

Name Description
data

Specifies the array associated with this Store.

errorHandler

Specifies the function called when the Store causes an error.

flushInterval

Specifies the time (in miliseconds) after the change operation, before the data is flushed.

immediate

Specifies whether the data is flushed immediatelly after each change operation, or after the delay specified via the flushInterval option.

key

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

name

The unique identifier used to distinguish the data within the HTML5 Web Storage.

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.

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.

clear()

Removes all data associated with this Store.

createQuery()

Creates the Query object for the underlying array.

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.