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
Export: default
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 the 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 property or properties.

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)

Gets a data item with a specific 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 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.