Try Xenarius Free

Data Connection

Supported Data

Xenarius can connect to the following:

  • OData service – Xenarius supports standard data access methods defined by the OData protocol and provides data fetching, server-side sorting and filtering.

  • REST service – you can connect to any other REST service. Use this approach if you prefer flexibility and wish to implement custom data access logic.

  • In-memory data – you can also create a data provider directly within the application.

  • Local store – provides access to HTML5 web storage.

Data Connection Basics

In a Xenarius app, each data connection is represented by a data provider. To access data providers, use the Data button in the main toolbar.

This button opens a menu and allows you to create a new data provider or to open/remove an existing one.

The data provider settings page is displayed when you create or open an existing data provider. This page contains a property grid that helps you set up your data provider.

Data provider properties can be bound to the global model.

After you set up a data provider, you can access it from functions or bind a data source to it.

The following properties are common for all data provider types:

  • Provider Type (required) – data connection type: OData, REST, In-memory Array or Local Store.

  • Provider ID (required) – a unique identifier for the data provider.

  • Key Property (required) – a property whose value uniquely identifies each record in the data provider.

OData Connection

OData data providers expose the following properties.

  • Name – the data provider name.

  • Production URL (required) – OData service URL used in production.

  • Development URL (optional) – OData service URL used during development and testing.

  • Key Property – the key property name.

  • Key Type (required) – key property data type.

  • Version (optional) – OData version. Default value is 2.

  • Send Cookies – if the options is enabled, authorization cookie will be passed to a server.

  • Headers (optional) – HTTP request headers that allow you to pass the operating parameters of an HTTP transaction. See example below.

  • Item Properties – lists properties for items returned by data provider service.

Note that if a service has CORS enabled, Xenarius automatically retrieves service metadata and specifies the Key, Key Type and Version properties. Otherwise, you need to specify them manually.

REST Connection

REST data providers expose the following properties.

  • Name – the data provider name.

  • Key Property – the key property name.

  • Data type – the type of data returned by data provider service.

  • Load (optional) – an HTTP request used to load all data.

  • By key (optional) – an HTTP request used to access an individual record.

  • Insert (optional) – an HTTP request used to insert a new record.

  • Update (optional) – an HTTP request used to change an existing record.

  • Remove (optional) – an HTTP request used to remove a record.

  • Total Count (optional) – an HTTP request used to obtain the total number of available records.

  • Headers (optional) – HTTP request headers that allow you to pass the operating parameters of an HTTP transaction. See example below.

  • Item Properties – lists properties for items returned by data provider service.

To build an HTTP request, specify the following properties.

  • Development URL Expression (optional) – an expression used to build a URL when debugging an application.

  • Production URL Expression (required) – an expression used to build a URL for a production application.

  • These are JavaScript expressions that return strings. The By key, Update and Remove request URLs should also reference the $key variable. This variable holds the value of the key property that identifies the record that needs to be returned, updated or removed respectively.

  • Get Request Parameter (optional) – a JavaScript expression used to build HTTP request arguments. Returns a JSON object with HTTP request parameters.

    Two notes:

    • These expressions can reference the global model by using the $global prefix.

    • You can also use data loading options to build the URLs and request arguments. To access them, use the $options prefix.

  • Request Method (optional) – an HTTP request method. Default values: GET for Load and By key requests, POST for Insert requests, PATCH for Update requests and DELETE for Remove requests.

The following example demonstrates how to configure HTTP request headers to pass an authentication token to a REST service.

Using in-Memory Data

The simplest data provider is an in-memory array. This provider stores data only for the current application session, the data is lost when the application is closed.

An in-memory array can be used in sample applications and for prototyping. It can also be used in a real application; for example, when you obtain a medium-sized array from a web service and then process it on the client side.

To create an array and add required values to it, use the Initial Array property. You can specify object properties in JSON format.

Sample array

Local Store

For working with HTML5 Web Storage, use a local store provider. Actually, it functions as an in-memory data provider. The difference is that the local store keeps data with no expiration date.

The local store provider exposes the following properties:

  • Name (required) – a unique identifier used to distinguish data within the storage.

  • Key Property – the key property name.

  • Save Immediately (optional) – specifies whether data is flushed immediately after each change operation, or after the delay specified via the Flush interval option.

  • Flush interval (optional) – specifies the time (in milliseconds) after the change operation, before data is flushed.

  • Initial Array - use this property to add the required objects to the array. You can specify object properties in JSON format.

  • Item Properties – lists properties for items returned by the data provider service.