Files
NativeScript/apps/tests/ui/repeater/repeater.md
Erjan Gavalji f15f283c74 Reorder test file structure to match the modules
Needed to have a nice structured cookbook dir in the docs

Includes:
Move the data-module tests under the data dir
Move the frame tests under the ui dir
Rename the dialog.md file to dialogs.md
Fix the web-view title
Add previous_url attributes to each article for SEO
Rename the style dir to styling to match the reference
Fix the frame-tests path
2016-05-05 10:43:35 +03:00

2.0 KiB

nav-title, title, description, previous_url
nav-title title description previous_url
repeater How-To repeater Examples for using repeater /ApiReference/ui/repeater/HOW-TO

Repeater

Using a Repeater requires the repeater module. Other modules which will be used in the code samples in this article:

Binding the Repeater items property to collection in the view-model.

<Page>
  {%raw%}<Repeater items="{{ myItems }}" />{%endraw%}
</Page>

Define the Repeater itemTemplate property.

<Page>
 {%raw%}<Repeater items="{{ myItems }}">
    <Repeater.itemTemplate>
       <Label text="{{ title || 'Downloading...' }}" textWrap="true" class="title" />
    </Repeater.itemTemplate>
 </Repeater>{%endraw%}
</Page>

Define the Repeater itemsLayout property. Default is StackLayout with orientation="vertical".

<Page>
 {%raw%}<Repeater items="{{ myItems }}">
    <Repeater.itemsLayout>
       <StackLayout orientation="horizontal" />
    </Repeater.itemsLayout>
 </Repeater>{%endraw%}
</Page>

Repeater with WrapLayout inside ScrollView.

<Page>
{%raw%}<ScrollView>
  <Repeater items="{{ myItems }}">
    <Repeater.itemsLayout>
       <WrapLayout />
    </Repeater.itemsLayout>
    <Repeater.itemTemplate>
       <Label text="{{ $value }}" margin="10" />
    </Repeater.itemTemplate>
  </Repeater>
 </ScrollView>{%endraw%}
</Page>

Using Repeater with Array

> Note, that changing the array after the repeater is shown will not update the UI. You can force-update the UI using the refresh() method. ### Using Repeater with different layout. ### Using Repeater with ObservableArray > When using ObservableArray the repeater will be automatically updated when items are added or removed form the array.