Data Layer Utils

This section describes the utility objects provided by the DevExtreme data layer.

Included in: dx.phonejs.js, dx.webappjs.js, dx.chartjs.js, dx.all.js

base64_encode(input)

Encodes the specified string or array of bytes to base64 encoding.

Parameters:
input: String|Array
A string or array of bytes to be encoded.
Return Value: String
The resulting **base64** string.

compileGetter(expr)

Compiles a getter function from the getter expression.

Parameters:
expr: String|Array
A getter expression.
Return Value: function
The resulting getter function.

This function is used internally by the data layer objects (DataSource and Stores). In most cases, you do not need to use it directly. For more information on getters, refer to the Data Layer article.

compileSetter(expr)

Compiles a setter function from the setter expression.

Parameters:
expr: String|Array
A getter expression.
Return Value: function
The resulting setter function.

This function is used internally by the data layer objects (DataSource and Stores). In most cases, you do not need to use it directly. For more information on setters, refer to the Data Layer article.

errorHandler

The global data layer error handler.

Type: function

This utility property takes on an error handling function, which is executed when any error occurs within the data layer. The function passed to this property takes on the JavaScript Error object as a parameter.

JavaScript
DevExpress.data.errorHandler = function(error) {
    console.log(error.message);
};

For more information on handling errors, refer to the Data Layer article.

odata.keyConverters

Holds key value converters for OData.

Type: Object

Use this object to register your own key type in addition to built-in types (String, Int32, Int64 and Guid).

JavaScript
DevExpress.data.utils.odata.keyConverters["MyType"] = function(value) {
    return value + "MT"; //returns an URL component for 'value'
};

The type converter is a function that takes on a value and returns a URL component for this value. For instance, the Int64 type converter takes on an integer value and returns a string representation of the initial value followed by "L" (555555 -> "555555L").

For more information on OData key types, refer to the Data Source Examples article.

query(array)

Creates a Query instance.

Parameters:
array: Array
The array associated with this Query.
Return Value: Object
The created Query instance.

For more information on Queries, refer to the Data Layer article.

query(url, queryOptions)

Creates a Query instance for accessing the remote service specified by a URL.

Parameters:
url: String
Specifies the URL of the remote data service.
queryOptions: Object
Specifies additional query options.
Return Value: Object
The created Query instance.

The object passed to the queryOptions argument should provide the adapter method implementing the remote data access logic, in addition to options passed to this method, because the queryOptions object is passed to the adapter method as well.

If you leave the adapter property unspecified, the default adapter implementing the OData protocol will be used.

The queryOptions object may also provide the errorHandler property specifying function handling errors that occurred within the Query.

For more information on Queries, refer to the Data Layer article.