ArrayStore

A Store accessing an in-memory array.

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

Object

To associate an array with the ArrayStore, pass this array to the ArrayStore constructor.

JavaScript
var store = new DevExpress.data.ArrayStore(array);

If you need to specify configuration options of the ArrayStore other than data, pass an object to the ArrayStore constructor.

JavaScript
var store = new DevExpress.data.ArrayStore({
    data: array,
    key: "id",
    onModified: function() {
        // 'modified' event handler
    },
    errorHandler: function(error) {
        // Error handler
    }
});

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

See Also

When using a widget as an ASP.NET MVC Control, declare the ArrayStore using the syntax shown in the following example. This example configures the SelectBox widget.

Razor C#
Razor VB
@(Html.DevExtreme().SelectBox()
    .ID("selectBox")
    .DataSource(ds => ds.Array()
        .Key("id")
        .Data(new[] {
            new { id = 1, state = "Alabama", capital = "Montgomery" },
            new { id = 2, state = "Alaska", capital = "Juneau" },
            new { id = 3, state = "Arizona", capital = "Phoenix" },
            // ...
        })
    )
    .DisplayExpr("state")
    .ValueExpr("id")
)
@* ===== or a simplified version ===== *@
@(Html.DevExtreme().SelectBox()
    .ID("selectBox")
    .DataSource(new[] {
        new { id = 1, state = "Alabama", capital = "Montgomery" },
        new { id = 2, state = "Alaska", capital = "Juneau" },
        new { id = 3, state = "Arizona", capital = "Phoenix" },
        // ...
    }, "id")
    .DisplayExpr("state")
    .ValueExpr("id")
)
@(Html.DevExtreme().SelectBox() _
    .ID("selectBox") _
    .DataSource(Function(ds)
        Return ds.Array() _
                 .Key("id") _
                 .Data({
                     New With { .id = 1, .state = "Alabama", .capital = "Montgomery" },
                     New With { .id = 2, .state = "Alaska", .capital = "Juneau" },
                     New With { .id = 3, .state = "Arizona", .capital = "Phoenix" }
                 })
    End Function) _
    .DisplayExpr("state") _
    .ValueExpr("id")
)
@* ===== or a simplified version ===== *@
@(Html.DevExtreme().SelectBox() _
    .ID("selectBox") _
    .DataSource({
        New With { .id = 1, .state = "Alabama", .capital = "Montgomery" },
        New With { .id = 2, .state = "Alaska", .capital = "Juneau" },
        New With { .id = 3, .state = "Arizona", .capital = "Phoenix" }
    }, "id") _
    .DisplayExpr("state") _
    .ValueExpr("id")
)

Configuration

This section describes configuration options used to configure the ArrayStore.

Name Description
data

Specifies the array associated with the Store.

errorHandler

Specifies the function called when the Store causes an error.

key

Specifies the key property or properties.

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 ArrayStore.

Name Description
byKey(key)

Gets a data item with a specific key.

clear()

Clears all data associated with the current ArrayStore.

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.