Data Sources

Last modified: August 20, 2024

Introduction

Widgets that display information stored in entities require you to assign a method by which to retrieve the relevant data. Such methods are collectively known as data sources. Widgets that require a data source include all data containers and input elements. Pluggable widgets can also use data sources.

This document describes data sources of data containers.

Data View

A data view supports the following data sources:

  • Context – the data view gets its object from the context: either from a page parameter or a surrounding data container.
  • Microflow – the data view object is determined by the result of calling the selected microflow. The microflow can take objects in the context as parameter and needs to return a single object.
  • Nanoflow – objects retrieved are determined by the result of calling the selected nanoflow. The nanoflow can take objects in the context as a parameter and needs to return a single object.
  • Listen to widget – the data view object depends on the selection in a list widget (a data grid, template grid, or list view).

List Widgets

Introduction

Data grids, template grids, and list views are list widgets. Also, some pluggable widgets may behave as list widgets and use data sources. Supported data sources are listed below:

  • Database – objects are retrieved from the database; database constraints can be used to limit which objects are shown.
  • XPath – objects are retrieved from the database; an XPath constraint can be used to constrain which objects are shown.
  • Microflow – objects retrieved are determined by the result of calling the selected microflow. The microflow can take objects in the context as parameter and needs to return a list of objects.
  • Nanoflow – objects retrieved are determined by the result of calling the selected nanoflow. The nanoflow can take objects in the context as a parameter and needs to return a list of objects. Nanoflow data source is only available for data views and list views.
  • Association – the objects are retrieved from memory by following an association from the object in the context. Thus, this data source is only available when a widget is nested in another data container.

The data source also determines which features of the widget are enabled. For example, only widgets with a database or XPath data source can contain a search bar.

Network Optimization Mode

At runtime, the client will retrieve the data which is configured in Studio Pro. The data can be retrieved in two possible modes depending on how the page is modeled: optimize for network round trips or optimize for network load.

You can see which of the modes is used in the Advanced tab of the data source properties.

If Network load is the default, you can change this to Network round trips. If Optimize for defaults to Network round trips then this is required by the client and cannot be changed.

The optimization mode cannot be changed for data grid, template grid, and list view widgets.

data source advanced tabpage

Optimize for Network Round Trips

In this mode, all the attributes of the data source entity are returned to the Mendix Client, even if not all these attributes are shown by the widget.

The advantage of this mode is that when a client action is triggered, an additional request to the Runtime Server can be prevented.

Optimize for Network Load

In this mode, only the attributes shown by the list widget are returned to the Mendix Client. This reduces the amount of data transferred over the network.

This means that when a client action is triggered, an additional request to the Mendix Runtime might be necessary.

Read More