How to use filter in primeng turbotable with lazy load?

筅森魡賤 提交于 2019-12-04 14:09:19

Here is one example:

template

  <ng-template pTemplate="header" let-columns>
    <tr>
      <th *ngFor="let col of columns" [style.width]="columnWidthTable(col.field)" [pSortableColumn]="col.field" [pSortableColumnDisabled]="!col.sortable">
        <p-sortIcon *ngIf="col.sortable" [field]="col.field"></p-sortIcon>
        {{col.field | translate}}
        <input (click)="$event.stopPropagation()" [style.width]="'90%'" *ngIf="col.filterable" pInputText type="text" (keyup.enter)="columnFilter($event, col.field)">
      </th>
    </tr>
  </ng-template>

component.ts

  @ViewChild('dt') dataTable: Table;
  columnFilter(event: any, field) {
    this.dataTable.filter(event.target.value, field, 'contains');
  }
David

I found the answer with PrimeNG lazy features and the source of this blog.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!