PrimeNG, p-table component when the data is reloaded the table resets to the first paginator tab.
Is there any way to stop that behaviour and make the paginator to remain in the same selected tab (for example 2 or 4 or 5 etc) when the data is reloaded?
I reload the data every 10 seconds by calling the RestAPI using setTimeout() in a loop till it stays on that page.
HTML
<p-table #dt [columns]="cols" [value]="dataMarts" [paginator]="true" [rows]="15" [pageLinks]="5" [rowsPerPageOptions]="[5,10,15,20,50,100,200,500,1000]"sortField="Id" resetPageOnSort="false">
Reference: https://www.primefaces.org/primeng/#/table
Not sure if this behaviour is something to do with the given explanation in section "Change Detection" of the above link.
Update:- This problem was actually caused by the attribute sortField="Id" which caused to always show the first tab. After removing it works fine.
[page]
input onp-table
where you can bind the current Page for the paginator. I'm sure you can come up with some logic to get the current Page from the paginator then rebind it – Chau Tranpage
actually available in the state of a paginator template.first
on the p-table is the index of the first row to be displayed. Is there a way for you to figure out what's the index of the first row on a current Page? – Chau Tran