0

I am using primeng turbo table with lazy loading and enabled loading to attribute it's not getting updated even got updated

<p-table #dt [loading]="loader" [columns]="cols" [value]="datasource.merchants" [rows]="perPage" [paginator]="true" [pageLinks]="5"
      [lazy]="true" [totalRecords]="datasource.totalCount" (onLazyLoad)="loadLazyData($event)" [exportFilename]="'merchant-list'">
.....

Script

loadLazyData(event: LazyLoadEvent) {    
    if (event.first !== this.searchParams.offset || event.rows !== this.searchParams.limit) {
      this.loader = true;
      this.searchParams.offset = event.first;
      this.searchParams.limit = event.rows;
     this.apiService.getResponse(this.smartSearchParams.query, event.first, event.rows)
          .subscribe((result) => {
            this.datasource = result;
            let newArray = result.merchants.slice();
            this.dataTable.value = newArray;
            setTimeout(() => {
              this.loader = false;
              this.dataTable.loading = this.loader;
            });
          }, (err: any) => {
            setTimeout(() => {
              this.loader = false;
              this.dataTable.loading = this.loader;
            });
          });

      }

can someone help me with this issue

Jasper de Vries
  • 19,370
  • 6
  • 64
  • 102
Satish
  • 537
  • 2
  • 9
  • 21
  • does this.loader = true ever get executed? of you remove the if statement does it work? if so the problem with related to your if statement conditions. – floor Feb 15 '18 at 14:59
  • @floor this.loader =true is got executed, value got updated but still loader is not stoping – Satish Feb 16 '18 at 10:06
  • do you have errors in the console? does your endpoint return data? – floor Feb 16 '18 at 15:35

1 Answers1

0

The issue is with changeDetection for the component.

I have removed the changeDetection:ChangeDetectionStrategy.OnPush from my component its started working

Satish
  • 537
  • 2
  • 9
  • 21