-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
{first} in currentPageReportTemplate always resolves to "1" even when no rows match #9002
Comments
how to resolve this issue currently?? |
This is an issue for our team as well. |
I created #9729 which should resolve this issue. In the meantime, one workaround I was able to get to work is to use a <p-table #table currentPageReportTemplate="Showing {first} to {last} of {totalRecords} entries"></p-table> export class TableComponent {
@ViewChild("table") table: Table
ngAfterViewInit(): void {
if (this.table.totalRecords === 0) {
this.table.currentPageReportTemplate = this.table.currentPageReportTemplate.replace("{first}", "0")
}
}
} |
according to your code suggestion this issue has not been resolved..when table has one row.According to your code it's showing 0 out of 1 of total record..in short your code has failed |
issue not resolved according to your code suggestion..please give me
another way
|
ngAfterViewChecked() { |
Ok, I will check.
*Thanks & Regards*
*Vinod Kr. Sahu*
*Software Engineer*
Meta*cube** Software Pvt. Ltd.*
SP-6, Phase IV, EPIP Sitapura, Jaipur, Rajasthan
Mobile: +91-
*9001857136*
…On Fri, Jan 15, 2021 at 3:38 PM anuragsadhu ***@***.***> wrote:
1. import - import { ChangeDetectorRef } from ***@***.***/core';
2. update constructor - constructor(private cdRef: ChangeDetectorRef)
3. use below code -
ngAfterViewChecked() {
if (this.table._totalRecords === 0) {
this.table.currentPageReportTemplate =
this.table.currentPageReportTemplate.replace("{first}", "0")
} else {
this.table.currentPageReportTemplate =
this.table.currentPageReportTemplate.replace("0", "{first}")
}
this.cdRef.detectChanges();
}
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#9002 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AMUAWOTHR3LVSJVKR6EGDZTS2AH3BANCNFSM4OPQ7TJQ>
.
|
I'm submitting a ...
Plunkr Case (Bug Reports)
Official Stackblitz for table component:
https://stackblitz.com/edit/primeng-tabledoc-demo
Current behavior
When there are no records loaded/no records matched on filtering, when using a template like "Showing {first} to {last} of {totalRecords} entries", {first} resolves to 1, leading to a rendered string "Showing 1 to 0 of 0 entries" which isn't technically correct
Expected behavior
When no suitable records are loaded, {first} resolves to 0 instead of 1, leading to the string "Showing 0 to 0 of 0 entries" which is accurate
Currently, a workaround to achieve this is to instead use your own template for the page report by using the paginatorright ng-template
Minimal reproduction of the problem with instructions
What is the motivation / use case for changing the behavior?
When there are no suitable records loaded into the table body, "0 to 0 of 0 records" is technically accurate
PrimeNG version: 9.1.0
Browser: all
Language: all
The text was updated successfully, but these errors were encountered: