DevExtreme React - Utils API
This section describes the utility objects that the DevExtreme data layer provides.
applyChanges(data, changes, options)
Applies an array of changes to a source data array.
Array<any>
A source data array to be updated.
Array<any>
An array of changes to be applied.
Configures how to apply changes.
| Name | Type | Description |
|---|---|---|
| immutable | If | |
| keyExpr | | | Specifies the key property (or properties) that provide(s) keys to locate data items. Default value: "id" |
If true (default), the source array remains unchanged; a new array with applied changes is returned.
If false, changes are applied directly to the source array which is then returned.
Specifies the key property (or properties) that provide(s) keys to locate data items. Default value: "id"
Array<any>
An array with applied changes.
base64_encode(input)
Encodes a string or array of bytes in Base64.
A Base64-encoded string.
- // ...
- import { base64_encode } from 'devextreme/data/utils';
- class App extends React.Component {
- constructor(props) {
- super(props);
- this.base64str = base64_encode("test");
- }
- // ...
- }
- export default App;
compileGetter(expr)
Compiles a getter function from a getter expression.
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.
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
Use the setErrorHandler instead.
Specifies the function that is executed when a data layer object throws an error.
A JavaScript Error object.
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.
The following code shows how to register a custom type converter:
- // ...
- import { keyConverters } from 'devextreme/data/odata/utils';
- class App extends React.Component {
- constructor(props) {
- super(props);
- keyConverters['MyType'] = value => {
- return value + 'MT';
- }
- }
- // ...
- }
- export default App;
See Also
query(array, queryOptions)
Creates a Query instance.
A Query instance.
- // ...
- import Query from 'devextreme/data/query';
- class App extends React.Component {
- constructor(props) {
- super(props);
- this.query = Query([10, 20, 50, 40, 30]);
- }
- // ...
- }
- export default App;
See Also
query(url, queryOptions)
Creates a Query instance that accesses a remote data service using its URL.
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.
- // ...
- import Query from 'devextreme/data/query';
- class App extends React.Component {
- constructor(props) {
- super(props);
- this.query = Query('http://mydomain.com/MyDataService', queryOptions);
- }
- // ...
- }
- export default App;
See Also
setErrorHandler
A method that specifies a function to be executed when a Data Layer component throws an error.
- import { setErrorHandler } from "data/errors";
- setErrorHandler(function(error) {
- console.log(error.message);
- });