ng-zorro-antd
ng-zorro-antd copied to clipboard
`nz-table` does not show pagination when `nzData` is an empty array
Reproduction link
https://stackblitz.com/edit/ng-zorro-antd-ivy-r8fnmf?file=src%2Fapp%2Fapp.component.ts
Steps to reproduce
Delete todo 4.
What is expected?
The pagination component should not be removed, and the pageIndex
should be normalized to 1
automatically by the nz-pagination
component. After the pageIndex
changed to 1, it should display 3 records in page 1.
What is actually happening?
Then the nz-pagination
component in nz-table
is removed.
Environment | Info |
---|---|
ng-zorro-antd | 16.2.0 |
Browser | Edge 118.0.2088.46 |
Is the current behavior expected? Relevant code stays unchanged for 3 years.
I think the current behavior is as expected. If you want to achieve the behavior you describe, you should use frontEnd pagination.
I think the current behavior is as expected. If you want to achieve the behavior you describe, you should use frontEnd pagination.
But in this example, we set nzTotal
to 3
, which implies data on other pages does exist. It's reasonable to show an empty table when nzData
is an empty array but removing the nz-pagination
component makes the user unable to switch to a different page. If this is expected, do you have any example or best practice for server pagination?
There should be a fallback logic on the server if the requested page is empty.
In your example, after id 4 is deleted and a request for pageIndex: 2
is sent, the server should return something like
{
total: 3,
pageIndex: 1,
pageSize: 3,
data: [1, 2, 3 ]
}
And you should use pageIndex
from the server in the frontend after that.
Explicitly, I need this for server side pagination.
When we have total
but still nzDate:[]
for any one pagination option then do not hide pagination setup.