我想在每行/單元格中使用帶有TextField和TextView的RadListView構建列表。該列表正確顯示,但是當列表足夠長時間滾動並且我在輸入字段中輸入任何內容(例如「hello」)並滾動時,「hello」將隨機移動到不同的項目。Nativescript RadListView輸入元素值在滾動時跳轉
示例: 列出50行。我在第1行的文本框中輸入「hello」。向下滾動,以便第1行不再可見。 「Hello」出現在第12行的文本字段中。我滾動回第1行,文本字段爲空。我向下滾動到第12行和空,但「你好」現在顯示了在排18的文本框...等
下面是代碼:
import { Component } from "@angular/core";
class DataItem {
constructor(public id: number, public name: string) { }
}
@Component({
selector: "orderpage_rad",
template: `
<StackLayout>
<RadListView [items]="myItems">
<ng-template tkListItemTemplate let-item="item" let-i="index">
<StackLayout>
<Label [text]='"index: " + i'></Label>
<Label [text]='"name: " + item.name'></Label>
<TextField keyboardType="number" hint="quantity"></TextField>
<TextView hint="enter text" editable="true"></TextView>
</StackLayout>
</ng-template>
</RadListView>
</StackLayout>
`
})
export class orderComponent_rad {
public myItems: Array<DataItem>;
private counter: number;
constructor(){
this.myItems = [];
this.counter = 0;
for (var i = 0; i < 50; i++) {
this.myItems.push(new DataItem(i, "data item " + i));
this.counter = i;
}
}
}
我正在與正常nativescript的ListView相同的結果,所以我不認爲它是一個錯誤。
我該如何解決這個問題?
我使用的角度與打字稿,至今只測試在Android:
TNS --version:3.1.2
跨平臺模塊版本:3.1.0