ODataStore

A Store providing access to a separate OData web service entity.

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

Object

To access the entire OData service, use the ODataContext object.

If you need to create a separate ODataStore instance, call the ODataStore constructor and specify the URL of the required entity via the url configuration option.

JavaScript
var store = new DevExpress.data.ODataStore({
    url: "/url/to/service",
    key: "CategoryID",
    keyType: "Int32"
});

Note that the key and keyType configuration options provide read-write access to the entity.

See Also

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

Razor C#
Razor VB
@(Html.DevExtreme().DataGrid()
    .ID("dataGrid")
    .DataSource(ds => ds.OData()
        .Version(4)
        .Url("http://services.odata.org/V4/Northwind/Northwind.svc/Products")
        .JSONP(true)
        .Key("ProductID")
        .Expand("Category")
    )
)
@(Html.DevExtreme().DataGrid() _
    .ID("dataGrid") _
    .DataSource(Function(ds)
        Return ds.OData() _
                 .Version(4) _
                 .Url("http://services.odata.org/V4/Northwind/Northwind.svc/Products") _
                 .JSONP(True) _
                 .Key("ProductID") _
                 .Expand("Category")
    End Function)
)
See Also

Configuration

This section describes the configuration options used to configure the ODataStore.

Name Description
beforeSend

A function used to customize a web request before it is sent.

deserializeDates

Specifies whether the store serializes/parses date-time values.

errorHandler

Specifies the function called when the Store causes an error.

fieldTypes

Specifies the types of data fields. Accepts the following types: "String", "Int32", "Int64", "Boolean", "Single", "Decimal" and "Guid".

jsonp

Specifies whether the ODataStore uses the JSONP approach to access non-CORS-compatible remote services.

key

Specifies the key property or properties.

keyType

Specifies the type of 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.

url

Specifies the URL of the OData entity to access.

version

Specifies the version of the OData protocol used to interact with the data service.

withCredentials

Specifies whether to send cookies and authorization headers to foreign domains in a cross-origin request.

Methods

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

Name Description
byKey(key)

Gets a data item with a specific key.

byKey(key, extraOptions)

Gets a data item with a specific key.

createQuery(loadOptions)

Creates a Query object for the OData endpoint.

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 ODataStore instance.

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.