简体   繁体   English

NativeScript RadList查看索引

[英]NativeScript RadListView index

I'm using NativeScript 6.1.1 and I have a RadListView in which I would like to have unique references for each row.我正在使用 NativeScript 6.1.1 并且我有一个 RadListView ,我想在其中为每一行提供唯一的引用。 One way I was thinking of is if I could get an index field then I could have the 'automationText' fields with the following我正在考虑的一种方法是,如果我可以获得一个索引字段,那么我可以拥有具有以下内容的“automationText”字段

name0
name1
name2

Here is my current template;这是我当前的模板;

<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>

Is it possible to do something like this?有可能做这样的事情吗?

        <Label automationText="name#{index}" row="0" col="0" class="nameLabel" [text]="item.name"></Label>

to get the index you may add let-i="index" to ng-template and consume it as automationText="name{{i}}"要获取索引,您可以将let-i="index"添加到 ng-template 并将其用作automationText="name{{i}}"

sample:样本:

<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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM