[英]NativeScript RadListView index
我正在使用 NativeScript 6.1.1 並且我有一個 RadListView ,我想在其中為每一行提供唯一的引用。 我正在考慮的一種方法是,如果我可以獲得一個索引字段,那么我可以擁有具有以下內容的“automationText”字段
name0
name1
name2
這是我當前的模板;
<RadListView automationText="listing"
[items]="dataItems"
[filteringFunction]="filterItems"
pullToRefresh="true"
(pullToRefreshInitiated)="onPullToRefreshInitiated($event)">
<ng-template tkListItemTemplate let-item="item">
<StackLayout orientation="vertical">
<GridLayout class="itemContainer" rows="50,*" columns="*,100">
<Label automationText="name" row="0" col="0" class="nameLabel" [text]="item.name"></Label>
</GridLayout>
</StackLayout>
</ng-template>
</RadListView>
有可能做這樣的事情嗎?
<Label automationText="name#{index}" row="0" col="0" class="nameLabel" [text]="item.name"></Label>
要獲取索引,您可以將let-i="index"
添加到 ng-template 並將其用作automationText="name{{i}}"
樣本:
<RadListView [items]="_dataItems" [itemTemplateSelector]="templateSelector">
<ng-template tkTemplateKey tkListItemTemplate let-item="item"
let-i="index">
<StackLayout>
<Label automationText="name{{i}}" text="name{{i}}"></Label>
</StackLayout>
</ng-template>
</RadListView>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.