[英]ng2-smart-table load data on scroll
i want to load data on scroll.我想在滚动上加载数据。 scroll is applied ng-card.
滚动应用 ng-card。
<nb-card> <nb-card-body class="patientInfoStyle"> <ng2-smart-table [settings]="settings" [source]="source" (deleteConfirm)="onDeleteConfirm($event)"> </ng2-smart-table> </nb-card-body> </nb-card>
Thanks in advance.提前致谢。
You may do this easily using ngx-infinite scroll .您可以使用ngx-infinite scroll轻松完成此操作。
There is also an interest solution when it comes to image lazy loading.当涉及到图像延迟加载时,还有一个有趣的解决方案。 Follow this
按照这个
This is not exactly the answer you were looking for but you can do the following:这不完全是您要寻找的答案,但您可以执行以下操作:
In my case I used Angular Material cdk .就我而言,我使用了Angular Material cdk 。 In order to use it with table in the library do the following:
为了将它与库中的表一起使用,请执行以下操作:
The code written by the author has good practices and easy to read.作者编写的代码实践良好,易于阅读。 doing it yourself is not too difficult.
自己做并不太难。 Also by doing above you can repeat this method with any open source libraries
此外,通过执行上述操作,您可以使用任何开源库重复此方法
I followed @olNoy advise and I created an alpha version of ng2-smart-table with scrolling of the body using angular-cdk scrolling.我按照@olNoy 的建议创建了 ng2-smart-table 的 alpha 版本,并使用 angular-cdk 滚动来滚动主体。
You could find it at https://github.com/andreatoppan/ng2-smart-table it is quite rude but I wanted to share if someone is interested, as it is working in my case.你可以在https://github.com/andreatoppan/ng2-smart-table 上找到它,这很粗鲁,但如果有人感兴趣,我想分享一下,因为它在我的情况下有效。
I treated the head and the body as 2 different tables, placing a cdk-virtual-scroll-viewport outside the tbody.我将头部和身体视为 2 个不同的表,在 tbody 外放置了一个 cdk-virtual-scroll-viewport。 This way the head will remain in place and the body could scroll over.
这样头部将保持原位,身体可以滚动。 The drawback of this approach is that the head and body column will be different, this is why I placed another head inside the second table and I created some not optimised functions to adjust the columns size in the component.
这种方法的缺点是 head 和 body 列会不同,这就是为什么我在第二个表中放置了另一个 head 并创建了一些未优化的函数来调整组件中的列大小。 If you find it useful you could expand or fix at your wish.
如果您发现它有用,您可以根据需要进行扩展或修复。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.