ng-zorro-antd
ng-zorro-antd copied to clipboard
how to control the row numbers in view, when use nzVirtual? 虚拟滚动,如何控制默认显示多少行
What problem does this feature solve?
设置表格为虚拟滚动,但是设置 scroll的 y值不生效;表格底部横线与 X滚动条未重合,中间有很大空白区域
What does the proposed API look like?
nzVirtualHeight
Translation of this issue:
How to control the row number in view, when use nzvirtual? Virtual scroll, how to control how many rows of the default display display is displayed
What PROBLEM DOES This Feature Solve?
Set the table for virtual rolling, but the Y value of the Scroll does not take effect; the horizontal line at the bottom of the form is not rearranged with the X rolling bar, and there is a large blank area in the middle
What does the proposed api look like?
nzvirtualHeight
hi zorro-bot, I tried this API 'nzVirtualHeight', but it dosen't work,
Hi, 请参考官网文档给出的示例,其中nzVirtualItemSize
为 item 高度,nzScroll.y
为虚拟滚动视口高度,默认显示行数 = nzScroll.y / nzVirtualItemSize
。
<nz-table
#virtualTable
[nzBordered]="true"
[nzVirtualItemSize]="54"
[nzData]="listOfData"
[nzVirtualForTrackBy]="trackByIndex"
[nzFrontPagination]="false"
[nzShowPagination]="false"
[nzScroll]="{ x: '1200px', y: '240px' }"
></nz-table>
若仍不能解决您的问题,请提供问题复现链接
@Laffery 是的, 按照官网连接, nzScroll.y 是控制显示行数的,但是很奇怪,比如我实际有30行数据,每一行高度nzVirtualItemSize =42, 总高度设置为6行的高度:252,就显示正常,底部的滚动条紧挨着表格底部;
但是如果我设置nzScroll.y大于300, 就会表格和底部滚动条有一段距离,像下图
看起来cdk的高度变化了,可是table的高度没变