【发布时间】:2016-10-20 13:42:12
【问题描述】:
我正在开发一个 Angular 2 应用程序,它必须以可滚动的方式显示大量数据 表。
数据在我的组件类中的一个数组中:
export class AppComponent {
clients: any[] = [];
constructor(){
for (var i = 0; i < 10; ++i) {
this.clients.push({
id: i,
name: 'Client' + i,
address: 'Address of client ' + i,
phone: '(51) 5454-4646'
});
}
}
}
然后在我的布局中通过 ngFor 加载数据:
<div style="height:600px;overflow:scroll">
<data-table>
<th>Id</th>
<th>Name</th>
<th>Address</th>
<th numeric>Phone</th>
<tr *ngFor="let client of clients">
<td>{{ client.id }}</td>
<td>{{ client.name }}</td>
<td>{{ client.address }}</td>
<td>{{ client.phone}}</td>
</tr>
</data-table>
</div>
例如,它必须将数据加载到一个有 10.000 行、可能有 20.000 行和大约 10 列的表中。这里的问题是加载速度很慢,加载后运行延迟很严重。
在这种情况下我不能使用分页,并且滚动是强制性的。我想保持滚动拇指的大小和位置,就好像所有数据都已加载一样,即使我需要做一些技巧,比如只加载部分数据。
我想知道在不减速的情况下完成这项任务的最佳做法是什么。
【问题讨论】:
-
试试 Material Virtual Scroll
标签: typescript angular html-table