reven
reven

Reputation: 340

PrimeNG p-table with paginator additional pages ignore "rows"

I'm using PrimeNGs p-table with [paginator]=true and rows=[10]. In my test set my data is 10000 items long (testing how well it works on large datasets). The first page shows 10 items correctly, but when I click next or a specific page number it shows 1000 items the first time, the second time I change pages it shows 2000 more (3000 in total) and so on...

Anyone know what I'm doing wrong

<p-table #dt [value]="items" [paginator]="true" rows="10" [globalFilterFields]="['id','hostname','logKeepDays']">
    <ng-template pTemplate="caption">
        <div style="text-align: right">        
            <i class="fa fa-search" style="margin:4px 4px 0 0"></i>
            <input type="text" pInputText size="50" placeholder="Filter..." (input)="dt.filterGlobal($event.target.value, 'contains')" style="width:auto">
        </div>
    </ng-template>
    <ng-template pTemplate="header">
        <tr>
          <th class="hidden-md-down" [pSortableColumn]="'id'">ID <p-sortIcon [field]="'id'"></p-sortIcon></th>
          <th [pSortableColumn]="'hostname'">Host <p-sortIcon [field]="'hostname'"></p-sortIcon></th>
          <th [pSortableColumn]="'active'">Active <p-sortIcon [field]="'active'"></p-sortIcon></th>
          <th [pSortableColumn]="'logKeepDays'">Log Days <p-sortIcon [field]="'logKeepDays'"></p-sortIcon></th>
        </tr>
    </ng-template>
    <ng-template pTemplate="body" let-item>
        <tr>
          <td class="hidden-md-down">{{item.id}}</td>
          <td>{{item.hostname}}</td>
          <td>{{item.active}}</td>
          <td>{{item.logKeepDays}}</td>
        </tr>
    </ng-template>
</p-table>

Upvotes: 1

Views: 1996

Answers (1)

reven
reven

Reputation: 340

I didnt have the square brackets around rows. changing rows="10" to [rows]="10" fixed it. odd that it works on the first page without the square brackets though.

But in case anyone every runs into this problem.

Upvotes: 3

Related Questions