primeng icon indicating copy to clipboard operation
primeng copied to clipboard

TurboTable with virtual scrolling: Problem with totalRecords

Open RichiKo opened this issue 8 years ago • 6 comments

I try to put dynamically totalRecords in my getData function and it doesn't seem to work with virtualscrolling. When I initialize it statically or set it to ngOnInit () it works. With paginator it also works.

Angular version: 5.2.1

PrimeNG version: 5.2.0-RC2

Browser: Chrome 62.0.3202.94 & Firefox ESR 45.2.0

Language: TypeScript 2.6

Node (for AoT issues): node --version = v8.9.4

RichiKo avatar Jan 26 '18 10:01 RichiKo

Same issue here

felipebri23 avatar Feb 05 '18 08:02 felipebri23

With DataTable it was possible to update totalRecords after initialization. TurboTable does not allow this anymore. If DataTable is now deprecated in favor of TurboTable, this should be supported.

thojo avatar Feb 21 '18 11:02 thojo

Something new about this

felipebri23 avatar Feb 28 '18 09:02 felipebri23

Same issue here. Without this feature I cannot migrate to TurboTable. In all projects totalRecords it's initialized dynamically when records and total of records are received from request.

lukgit17 avatar Mar 09 '18 08:03 lukgit17

Duplicate of https://github.com/primefaces/primeng/issues/5303

Came across the same issue and found out that totalRecords are not getting updated at first . Tried to set totalRecords via the table instance followed by its updateRecord method but it did not help.

Finally did some hack to rerender the view based on a flag value as below <p-table *ngIf = "render" [value]="values" [totalRecords]="totalRecords" ... >

In component

ngOnInit(){
  this.totalRecords : number = 0;
  this.render : boolean = true;
}

modifyRecords(records){
  this.render = false;
  this.values = records;
  this.totalRecords = records.length;
  setTimeout(() => {
    this.render = true;
   },0);
}

**setTimeout was the key for me , as the flag change needed some delay.

This solution may not be idealistic , but it worked perfectly for me without any performance issue.

Abhi-99 avatar Mar 14 '18 10:03 Abhi-99

https://github.com/primefaces/primeng/issues/5303

cagataycivici avatar Mar 27 '18 08:03 cagataycivici