As mentioned previously, to bind an aggregation, you create a template or provide a factory function.
This section shows how to work with a template control in an XML view. In the example shown here, the entries from an array are to be displayed via a sap.m.Table UI element (see figure Model Data).
The columns aggregation is used to define the three columns of the table with their headers (see the figure Data Binding). No data binding is used for this yet.
For the display of the data, a binding to the items aggregation of the sap.m.Table UI element is applied. The items aggregation defines the entries displayed in the table.
The items="{/Customers}" attribute of the <Table> tag is used to pass the elements of the Customers array from the JSON model to the items aggregation of the table. The absolute binding path /Customers is needed for this purpose.
The aggregation binding requires the definition of a template that is cloned for each element of the passed array. For each clone that is created, the binding context is thereby set to the respective array element, so that all bindings of the template are resolved relative to the array element.
The template can be found in the nested items element in the figure Data Binding. It is a sap.m.ColumnListItem control that creates a new row for the table. This row displays customer name, street as well as city from the respective array element.
Note
The binding paths used within the sap.m.ColumnListItem
control are all relative, as they are resolved relative to the array element for which the template is cloned.