Configuration
This section describes configuration options used to configure the ODataContext.
beforeSend
A function used to customize a web request before it is sent.
The method passed to this option should take on a request object as a parameter, which provides the following fields.
- async - specifies whether the request is asynchronous or synchronous.
- method - a string representing the request method ("GET" or "POST")
- url - the request URL
- params - the 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.
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.
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.
The function passed to this option takes on the JavaScript Error object as a parameter.
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.
withCredentials
Specifies the value of the withCredentials field of the underlying jqXHR object.
Setting this option to true enables the sending of cookies and authorization headers to foreign domains (CORS-related).