Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to control the row numbers in view, when use nzVirtual? 虚拟滚动,如何控制默认显示多少行 #8441

Open
XimenaWang opened this issue Mar 15, 2024 · 4 comments

Comments

@XimenaWang
Copy link

What problem does this feature solve?

设置表格为虚拟滚动,但是设置 scroll的 y值不生效;表格底部横线与 X滚动条未重合,中间有很大空白区域

What does the proposed API look like?

nzVirtualHeight

Copy link

zorro-bot bot commented Mar 15, 2024

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

@XimenaWang
Copy link
Author

hi zorro-bot, I tried this API 'nzVirtualHeight', but it dosen't work,

@Laffery
Copy link
Collaborator

Laffery commented Mar 18, 2024

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>

若仍不能解决您的问题,请提供问题复现链接

@XimenaWang
Copy link
Author

XimenaWang commented Mar 18, 2024

@Laffery 是的, 按照官网连接, nzScroll.y 是控制显示行数的,但是很奇怪,比如我实际有30行数据,每一行高度nzVirtualItemSize =42, 总高度设置为6行的高度:252,就显示正常,底部的滚动条紧挨着表格底部;

但是如果我设置nzScroll.y大于300, 就会表格和底部滚动条有一段距离,像下图
image

看起来cdk的高度变化了,可是table的高度没变
image
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants