Show TOC

repeatLocate this document in the navigation structure

The <template:repeat instruction iterates the sap.ui.model.ListBinding given by the list attribute.


Sorting and filtering is already supported by the list binding via an extended syntax. For more information, see Using Extended Syntax to Add Filters and Sorters.

The var attribute holds the name of the loop variable which can be used to access the current list element in a child element of repeat. In the preprocessing, repeat is replaced by multiple clones of its content, one clone per list element, with each clone again preprocessed as if it were contained in a with instruction defining the loop variable.

The following example iterates all fields in the identification annotation from the SAP UI vocabulary in the currently referenced element of the model meta and displays a label and content for each field. It is completely transparent to the repeat implementation whether the list binding refers to data or meta data. The templating engine is replacing "template time" binding expressions which refer to meta data with corresponding runtime binding expression which refer to data. The formatter sap.ui.model.odata.AnnotationHelper.format is used, which encapsulates knowledge about the SAP UI vocabulary and so on.


Template for "repeat" Instruction
<template:repeat list="{meta>}" var="field">
  <Label text="{path: 'field>Label', formatter: 'sap.ui.model.odata.AnnotationHelper'}" />
  <Text text="{path: 'field>Value', formatter: 'sap.ui.model.odata.AnnotationHelper'}" />


Output Template for the "repeat" Instruction (in Memory Only)
<Label text="Product ID" />
<Text text="{path:'ProductID',type:'sap.ui.model.odata.type.String',constraints:{"nullable":false,"maxLength":10}}" />
<Label text="Price" />
<Text text="{path:'Price/Amount',type:'sap.ui.model.odata.type.Decimal',constraints:{"precision":13,"scale":3}}" />
<Label text="Category" />
<Text text="{path:'Category',type:'sap.ui.model.odata.type.String',constraints:{"maxLength":40}}" />
<Label text="Supplier" />
<Text text="{path:'SupplierName',type:'sap.ui.model.odata.type.String',constraints:{"maxLength":80}}" />