Configuration

This section describes configuration options used to configure the ODataContext.

beforeSend

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

Type:

function

Function parameters:
options:

Object

The request parameters.

Object structure:
url:

String

The request URL.

async:

Boolean

Specifies whether the request is asynchronous or synchronous.

method:

String

The request method ("GET", "POST", "PATCH", or "MERGE").

timeout:

Number

The request timeout.

params:

Object

The additional request parameters.

payload:

Object

The request body; for example, when updating an item, this property holds the values object.

headers:

Object

The request headers.

deserializeDates

Specifies whether to deserialize dates found in the response.

Type:

Boolean

The underlying ODataStore can deserialize dates represented in the ISO8601 format (for example, "2016-07-13T16:05:00.000Z") or format used by Microsoft (for instance, "/Date(1198908717056)/"). In the second case, the ODataStore adds the time-zone offset corresponding to the client's time-zone. In the first case, the ODataStore parses the date string without taking a timezone modifier (for example, "Z") into account.

entities

Specifies the list of entities to be accessed with the ODataContext.

Type:

Object

The object passed to this option should contain Fields whose names equal the corresponding entity names. The ODataContext will create an ODataStore instance for each entity. Therefore, each of these properties takes on an ODataStore configuration object.

JavaScript
var context = new DevExpress.data.ODataContext({
    url: "http://www.example.com/Northwind.svc",
    entities: {
        Categories: { 
            key: "CategoryID", 
            keyType: "Int32" 
        },
        MyCustomers: { 
            name: "Customers",
            key: "CustomerID", 
            keyType: "String" 
        }
    }
});

errorHandler

Specifies the function called if the ODataContext causes an error.

Type:

function

The function passed to this option takes on the JavaScript Error object as a parameter.

JavaScript
var context = new DevExpress.data.ODataContext({
    url: "http://www.example.com/Northwind.svc",
    errorHandler: function(error) {
        alert(error.message);
    },
    entities: {
        Categories: {
            key: "CategoryID",
            keyType: "Int32"
        },
        MyCustomers: {
            name: "Customers",
            key: "CustomerID",
            keyType: "String"
        }
    }
});

jsonp

Specifies whether to use JSONP to access CORS-incompatiable remote services.

Type:

Boolean

Default Value: false

url

Specifies the URL of the data service being accessed via the current ODataContext.

Type:

String

version

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

Type:

Number

Default Value: 2
Accepted Values: 2 | 3 | 4
NOTE
If the version option holds 2, ODataContext uses the "MERGE" method to send requests. Otherwise, it uses the "PATCH" method. To override this behavior, use the beforeSend option.

withCredentials

Specifies the value of the withCredentials field of the underlying jqXHR object.

Type:

Boolean

Default Value: false

Setting this option to true enables the sending of cookies and authorization headers to foreign domains (CORS-related).