Refresh the data and paginator state

E.Meir picture E.Meir · Jul 31, 2018 · Viewed 7.3k times · Source

I am using PrimeNG Turbotable <p-table #dt.

According this dt.reset() will reset sort, filter and paginator state. I am trying to find a way to reset paginator state and reload table data. (without the sort state reset)

This should happen on (click) of that button enter image description here

<p-button icon="fa fa-refresh" (click)="refresh()"></p-button>

How can I achieve that ?

Answer

harsh.tibrewal picture harsh.tibrewal · May 1, 2020

In .html file -

<p-table #dt [columns]="cols" [value]="result" [paginator]="true" [rows]="10" [(first)]="first">

Don't forget the brackets in [(first)]

In .ts file, Add first attribute :

first = 0

wherever you want to reset, call below mentioned refresh function

refresh() {
    this.first = 0;
}