Ilya
Ilya

Reputation: 29721

PrimeNG table saves selected page after value change

I have simple PrimeNG table

<p-table [value]="users"
          [paginator]="true" 
          [rows]="5">
  <ng-template pTemplate="header">
    <tr>
      <th>name</th>
    </tr>
  </ng-template>
  <ng-template pTemplate="body" let-user>
    <tr>
      <td>{{user}}</td>
    </tr>
  </ng-template>
</p-table>

And more then 5 users in table

users: string[] = ['Mike', 'David', 'John', 'Ronald', 'Mark', 'Polina', 'Anna', 'Olivia', 'Amelia'];

Select second page in table and then assign new value to this.users

this.users = ['Gregor', 'Ronald'];

But second page is still selected in table, so there is no users in table. See live DEMO

I demo just delect second page and click 'Change names'. New names are not visible.

Is there a way to fix it from code?

Upvotes: 3

Views: 707

Answers (1)

Uğur Din&#231;
Uğur Din&#231;

Reputation: 2455

According to this answer, you are out of luck. Limitations are unfortunately part of life when it comes to these frameworks.

However, you can always hack it using the hammer and dynamite approach.

See the updated plunk.

Upvotes: 1

Related Questions