【发布时间】:2019-11-26 11:19:35
【问题描述】:
我需要在我的 Angular 8 Web 应用程序的一个页面中呈现一个包含 10k+ 行数据(每行 15+ FormControls)的 FormArray 的表单。由于这些大量数据,存在很大的渲染问题,有人可以帮助我提高渲染性能吗?谢谢
我曾尝试将 virtualScroll 与 @angular/cdk 一起使用,但效果仍然不佳
<table [formGroup]="validateForm">
<thead>
<tr>
<th *ngFor="let column of columns">{{column.name}}</th>
</tr>
</thead>
<ng-container formArrayName="rows"
*ngIf="inputDataValid(rowDatas, columns)">
<tbody *cdkVirtualFor="let row of rowDatas; let rowIndex = index; "
[formGroupName]="rowIndex"
class="example-item"
>
<tr>
<td *ngFor="let column of columns;">
<input type="text"
[formControlName]="column.prop"
*ngIf="column.controlType === controlTypes.TEXT">
<select name=""
id=""
[formControlName]="column.prop"
*ngIf="column.controlType === controlTypes.SELECT">
<!-- options -->
</select>
</td>
</tr>
</tbody>
</ng-container>
</table>
【问题讨论】:
-
为什么不分页呢?使用无限滚动或只是加载更多按钮。
-
当然,同时所有 10k 行不是必需的?是学校项目吗?如果是现实世界,分页就是答案。
-
我会使用虚拟滚动进行分页
-
很遗憾,不允许分页,这是用户的具体要求,在一页中显示和修改这些数据
标签: angular typescript angular-reactive-forms large-data formarray