Repeater
import { Repeater } from 'cx/widgets';Repeater renders the content of each record from the assigned collection.
Within Repeater, use the $record alias to access the record data.
Element index is available by using the $index alias.
<Repeater records-bind="intro.core.items">
<Checkbox value-bind="$record.checked" text-bind="$record.text" />
<br/>
</Repeater>
You checked <Text value-expr="{intro.core.items}.filter(a => a.checked).length" /> item(s).If sortField is set, the collection will be sorted before output.
By default, Repeater maintains the order of elements in the collection.
Here is a modified version of the previous example with elements
arranged in descending order:
Sometimes it is useful to change the default record and index aliases ($record and $index),
e.g. when nesting one Repeater inside another. This can be done by setting
the recordAlias and indexAlias attributes.
<Repeater
records-bind="bank.transactions"
recordAlias="account"
>
<Text tpl="Account ID: {account.accountId}" />
<br/>
<Repeater
records-bind="account.transactions"
recordAlias="transaction"
indexAlias="transactionIndex"
>
<Text tpl="{transactionIndex} - {transaction.action} ${transaction.amount} " />
<Text tpl="to {transaction.to}" if-expr="{transaction.action} === 'send'" />
<Text tpl="from {transaction.from}" if-expr="{transaction.action} === 'receive'" />
<br />
</Repeater>
<br />
</Repeater>| Property | Description | Type |
|---|---|---|
indexAlias | Alias used to expose record index. Defaults to | string |
recordAlias | Alias used to expose record data. Defaults to | string |
records | An array of records to be shown. | array |
sortDirection | A binding used to store the sort direction. Available only if | string |
sortField | A binding used to store the name of the field used for sorting the collection.
Available only if | string |
sorters | A binding used to store the sorting order list.
This should be an array of objects with | array |
onTrackMappedRecords | Callback function to track and retrieve displayed records. Accepts new records as a first argument. If onCreateFilter callback is defined, filtered records can be retrieved using this callback. | function |
sortOptions | Options for data sorting. See Intl.Collator options for more info. | record |