Utils

This section describes the utility objects that the DevExtreme data layer provides.

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

base64_encode(input)

Encodes a string or array of bytes in Base64.

Module: data/utils
Export: base64_encode
Parameters:
input:

String

|

Array<Number>

A string or array of bytes to be encoded.

Return Value:

String

A Base64-encoded string.

jQuery
JavaScript
var base64str = DevExpress.data.base64_encode("test");
Angular
TypeScript
import { base64_encode } from "devextreme/data/utils";
// ...
export class AppComponent {
    constructor () {
        let base64str = base64_encode("test");
    }
}

compileGetter(expr)

Compiles a getter function from a getter expression.

Module: utils
Export: compileGetter
Parameters:
expr:

String

|

Array<String>

A getter expression.

Return Value:

Function

A getter function.

The DataSource and stores use this method internally - you do not need to use it directly. Refer to Getters and Setters for more information.

compileSetter(expr)

Compiles a setter function from a setter expression.

Module: utils
Export: compileSetter
Parameters:
expr:

String

|

Array<String>

A setter expression.

Return Value:

Function

A setter function.

The DataSource and stores use this method internally - you do not need to use it directly. Refer to Getters and Setters for more information.

errorHandler

Specifies the function that is executed when a data layer object throws an error.

Module: data/errors
Export: errorHandler
Type:

Function

Function parameters:

A JavaScript Error object.

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

odata.keyConverters

Contains built-in OData type converters (for String, Int32, Int64, Boolean, Single, Decimal, and Guid) and allows you to register a custom type converter.

Export: keyConverters
Type:

Object

The following code shows how to register a custom type converter:

jQuery
JavaScript
DevExpress.data.utils.odata.keyConverters["MyType"] = function (value) {
    return value + "MT";
};
Angular
TypeScript
import { keyConverters } from "devextreme/data/odata/utils";
// ...
export class AppComponent {
    constructor () {
        keyConverters["MyType"] = value => {
            return value + "MT"
        }
    }
}
See Also

query(array)

Creates a Query instance.

Module: data/query
Export: default
Parameters:
array:

Array<any>

Data to be associated with the Query.

Return Value:

Query

A Query instance.

jQuery
JavaScript
var query = DevExpress.data.query([10, 20, 50, 40, 30]);
Angular
TypeScript
import Query from "devextreme/data/query";
// ...
export class AppComponent {
    constructor () {
        let query = Query([10, 20, 50, 40, 30]);
    };
}
See Also

query(url, queryOptions)

Creates a Query instance that accesses a remote data service using its URL.

Module: data/query
Export: default
Parameters:
url:

String

The data service's URL.

queryOptions:

Object

Additional query options.

Return Value:

Query

A Query instance.

The queryOptions object should contain the adapter function that implements data access logic. The queryOptions object can also contain the errorHandler function for handling errors that may occur during the Query's execution.

jQuery
JavaScript
var query = DevExpress.data.query("http://mydomain.com/MyDataService", queryOptions);
Angular
TypeScript
import Query from "devextreme/data/query";
// ...
export class AppComponent {
    constructor () {
        let query = Query("http://mydomain.com/MyDataService", queryOptions);
    };
}
See Also