'ng zorro table with pagination
I am having an issue ng zorr table with pagination. Uing pagination with seperate component like below
<nz-table #dynamicTable
[nzScroll]="fixHeader ? { y: '240px' } : null"
[nzData]="countryList"
[nzLoading]="loading"
[nzShowPagination]="false"
[nzFooter]="footer ? 'Sayfalama' : null"
[nzTitle]="title ? 'Müşteri Listesi' : null"
[nzSize]="size">
<thead>
<tr *ngIf="header">
<!-- <th nzWidth="50px"></th>-->
<th nzWidth="150px">Kod</th>
<th nzWidth="70px">Ad</th>
<th>3'lü kod</th>
<th nzWidth="260px">Telefon kodu</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let data of dynamicTable.data">
<!-- <td nzShowCheckbox *ngIf="checkbox" [(nzChecked)]="data.checked"></td>-->
<td>{{ data.code }}</td>
<td>{{ data.name }}</td>
<td>{{ data.tripleCode }}</td>
<td>{{ data.phoneCode }}</td>
</tr>
</tbody>
</nz-table>
<br>
<nz-pagination class="pagination" nzShowSizeChanger nzShowQuickJumper [nzTotal]="total" [(nzPageIndex)]="pageIndex" [(nzPageSize)]="pageSize"
(nzPageSizeChange)="pageSizeChanged($event)" (nzPageIndexChange)="pageIndexChanged($event)"
[nzPageSizeOptions]="pageSizeOptions">
</nz-pagination>
The problem is when I set the total record of data which also getting it from API as below. Table show only 10 record whatever total count is.
loadPage() {
this.apiService.postAny(['ListAsync'], null, this.filterModel).subscribe(data => {
if (this.apiService.checkResponse(data)) {
this.loading = false;
this.total = data.result.count;
this.countryList = [];
this.countryList = data.result.result as CountryListModel[];
}
}, error => {
console.log(error);
}, () => {
console.log('Country load completed !');
});
}
API return 17 records but table show only 10 record. If I use page navigation with page number I can see all record with page size. But If I change the directly page size (for example set it 20 per page) table only shoing 10 records nothing more. But API returns as expected.
Solution 1:[1]
You need add [nzTotal] for count pages and [pageIndex], [pageSize]
Solution 2:[2]
just add [nzFrontPagination]=false
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Acid_st |
Solution 2 | M s |