Angular 为什么p-table的p-pagination不起作用

Angular 为什么p-table的p-pagination不起作用,angular,primeng,Angular,Primeng,我正在实施p-pagination,p-table中的数据应该相应地反映出来。 如果我在p-table中通过[pagination]=“true”使用它,它是有效的,但我想实现的是使用paginationModule。在这种情况下,数据不会根据分页中的页面选择显示。 请帮帮我 <p-dialog [(visible)]="mSerivce.isAuditDialogVisible" [draggable]="false" [closable]="true" showEff

我正在实施p-paginationp-table中的数据应该相应地反映出来。 如果我在p-table中通过[pagination]=“true”使用它,它是有效的,但我想实现的是使用paginationModule。在这种情况下,数据不会根据分页中的页面选择显示。 请帮帮我

<p-dialog 
  [(visible)]="mSerivce.isAuditDialogVisible"
  [draggable]="false"
  [closable]="true"
  showEffect="fade"
  [contentStyle]="{width:'800px', height:'400px'}" >
  <p-header>
    Audit History
  </p-header>
  <p-table [value]="auditHistoryList" [columns]="auditGridColumns" [responsive]="true">
    <ng-template pTemplate="colgroup" let-columns>
      <colgroup>
        <col *ngFor="let col of columns" [style.width]="col.style" />
      </colgroup>
    </ng-template>
    <ng-template pTemplate="header" let-columns>
      <tr class="st-sub-header">
        <th *ngFor="let col of columns">
          {{col.header}}
        </th>
      </tr>
    </ng-template>
    <ng-template pTemplate="body" class="tb-body" let-rowIndex="rowIndex" let-rowData let-expanded="expanded" let-columns="columns">
      <tr>
        <td class="h-90 mh-20">{{rowData.action || '-'}}</td>
        <td class="h-90">{{rowData.user}}</td>
        <td class="h-90">{{rowData.createdDate || '-'}}</td>
        <td class="h-90" [innerHTML]="rowData?.comments || '-'"></td>
      </tr>
    </ng-template>
    <ng-template pTemplate="emptymessage" let-columns>
      <tr>
        <td colspan="4">
          No records found
        </td>
      </tr>
    </ng-template>
  </p-table>
  <p-footer>
    <p-paginator [rows]="2" [totalRecords]="auditHistoryList.length" pageLinkSize="3"></p-paginator>
  </p-footer>
</p-dialog>

审计历史
{{col.header}}
{{rowData.action | |'-'}}
{{rowData.user}
{{rowData.createdDate | |'-'}}
没有发现任何记录

我也有类似的问题。然而,我能看到的你的代码和我的代码之间的唯一区别是如何使用paginator。也许你可以试着这样做:

<p-table #myTable [value]="auditHistoryList" [paginator]="true" [rows]="2">
...
this.auditHistoryList.push(auditHistory);
this.myTable.totalRecords = this.auditHistoryList.value.length;
考虑到myTable是p-table组件的ViewChild:

import { Table } from 'primeng/table';
...
@ViewChild(Table, {static: false}) myTable : Table;

我希望这会有帮助。

我也遇到过类似的问题。然而,我能看到的你的代码和我的代码之间的唯一区别是如何使用paginator。也许你可以试着这样做:

<p-table #myTable [value]="auditHistoryList" [paginator]="true" [rows]="2">
...
this.auditHistoryList.push(auditHistory);
this.myTable.totalRecords = this.auditHistoryList.value.length;
考虑到myTable是p-table组件的ViewChild:

import { Table } from 'primeng/table';
...
@ViewChild(Table, {static: false}) myTable : Table;
我希望这会有帮助