Configuration

This section describes configuration options used to configure the ODataContext.

beforeSend

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

Type: function

The method passed to this option should take on a request object as a parameter, which provides the following fields.

  • method - a string representing the request method ("GET" or "POST")
  • url - the request URL
  • params - additional request parameters
  • payload - the request body; for example, when updating an item, this property holds the value object
  • headers - an object holding the request headers
  • timeout - the request timeout

entities

Specifies the list of entities to be accessed via 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 the ODataStore uses the JSONP approach to access non-CORS-compatible 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

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