
Aggregation binding allows a control to be bound to a list within the model data and allows relative binding to the list entries by its child controls.
Use template control that is cloned as many times as needed to display the data.
Use a factory function to generate the correct control per bound list entry based on the data received at runtime.

You can view and download all files in the Explored app in the Demo Kit under Data Binding - Step 12.
...
// ----------------------------------------------------------------------
var oProductModel = new sap.ui.model.json.JSONModel();
oProductModel.loadData("./model/Products.json");
sap.ui.getCore().setModel(oProductModel, "products");
...
<attributes>
<ObjectAttribute text="{ path: 'Status', formatter: '.formatStatusText' }"/>
</attributes>
</ObjectListItem>
</items>
</List>
</content>
</Panel>
<Panel headerText="{i18n>panel3HeaderText}" class="sapUiResponsiveMargin" width="auto">
<content>
<List headerText="{i18n>productListTitle}" items="{products>/Products}">
<items>
<ObjectListItem title="{products>ProductName}"
number="{ parts: [{path: 'products>UnitPrice'},
{path: '/currencyCode'}],
type: 'sap.ui.model.type.Currency',
formatOptions: { showMeasure: false }
}"
numberUnit="{/currencyCode}">
<attributes>
<ObjectAttribute text="({products>QuantityPerUnit})" />
<ObjectAttribute title="{path: 'i18n>stockValue'}"
text="{parts: [{path: 'products>UnitPrice'},
{path: 'products>UnitsInStock'},
{path: '/currencyCode'}],
formatter: '.formatStockValue' }" />
</attributes>
</ObjectListItem>
</items>
</List>
</content>
</Panel>
</mvc:View>
We add a new panel to the view.
...
formatStockValue: function(fUnitPrice, iStockLevel, sCurrCode) {
var sBrowserLocale = sap.ui.getCore().getConfiguration().getLanguage();
var oLocale = new sap.ui.core.Locale(sBrowserLocale);
var oLocaleData = new sap.ui.core.LocaleData(oLocale);
var oCurrency = new sap.ui.model.type.Currency(oLocaleData.mData.currencyFormat);
return oCurrency.formatValue([fUnitPrice * iStockLevel, sCurrCode], "string");
};
{ "Products": [ {
"ProductID": 1,
"ProductName": "Chai",
"SupplierID": 1,
"CategoryID": 1,
"QuantityPerUnit": "10 boxes x 20 bags",
"UnitPrice": "18.0000",
"UnitsInStock": 39,
"UnitsOnOrder": 0,
"ReorderLevel": 10,
"Discontinued": false
}, {
"ProductID": 2,
"ProductName": "Chang",
"SupplierID": 1,
"CategoryID": 1,
"QuantityPerUnit": "24 - 12 oz bottles",
"UnitPrice": "19.0000",
"UnitsInStock": 17,
"UnitsOnOrder": 40,
"ReorderLevel": 25,
"Discontinued": true
}, {
"ProductID": 3,
"ProductName": "Aniseed Syrup",
"SupplierID": 1,
"CategoryID": 2,
"QuantityPerUnit": "12 - 550 ml bottles",
"UnitPrice": "10.0000",
"UnitsInStock": 0,
"UnitsOnOrder": 70,
"ReorderLevel": 25,
"Discontinued": false
}, {
"ProductID": 4,
"ProductName": "Chef Anton's Cajun Seasoning",
"SupplierID": 2,
"CategoryID": 2,
"QuantityPerUnit": "48 - 6 oz jars",
"UnitPrice": "22.0000",
"UnitsInStock": 53,
"UnitsOnOrder": 0,
"ReorderLevel": 0,
"Discontinued": false
}, {
"ProductID": 5,
"ProductName": "Chef Anton's Gumbo Mix",
"SupplierID": 2,
"CategoryID": 2,
"QuantityPerUnit": "36 boxes",
"UnitPrice": "21.3500",
"UnitsInStock": 0,
"UnitsOnOrder": 0,
"ReorderLevel": 0,
"Discontinued": true
}]
}We now use a new JSON model file for product data.
... # Screen titles panel1HeaderText=Data Binding Basics panel2HeaderText=Adress Details panel3HeaderText=Aggregation Binding # Invoice List invoiceListTitle=Invoices statusA=New statusB=In Progress statusC=Done # Error messages invalidDate=Invalid Date Format # Product list productListTitle=Product List stockValue=Current Stock Value
... # Screen titles panel1HeaderText=Data Binding Basics panel2HeaderText=Adressdetails panel3HeaderText=Aggregation Binding # Invoice List invoiceListTitle=Rechnungen statusA=Neu statusB=Laufend statusC=Abgeschlossen # Error messages invalidDate=Ungültiges Datumsformat # Product list productListTitle=Artikelliste stockValue=Lagerbestand Wert
We add the missing texts.