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 configuring a widget using ASP.NET MVC Wrappers, 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 this Store.

errorHandler

Specifies the function called when the Store causes an error.

key

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

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)

Returns the data item specified by the 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 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.