PrimeNg p-table 的类型定义
Type definition for PrimeNg p-table
我有一个 PrimeNg p-table,我需要根据用户设置默认过滤,所以我想我需要使用类似 let table = document.getElementById("dt");
的东西,其中 table 是 primeNg 的table 对象是这样我可以像在 html 中那样调用 table.filter(filterDefault, col.field, 'in');
。我只是不知道如何将 #dt
作为正确的类型传递到我的打字稿中,或者也许有一种更简单的方法可以使用 p-table 已有的内容来完成此操作。
<p-table #dt>
...
<tr>
<th *ngFor="let col of columns" [ngSwitch]="col.filterType" class=showOverflow pResizableColumn>
...
<p-multiSelect *ngSwitchCase="'DropDown'" [options]="masterSearchTypes" defaultLabel="All"
[(ngModel)]="filterDefault" (onChange)="dt.filter($event.value, col.field, 'in' )"></p-multiSelect>
</th>
</tr>
...
</p-table>
在你的 TS 文件中使用 @Viewchild :
import { ViewChild } from '@angular/core';
import { Table } from 'primeng/table';
@ViewChild('dt') table: Table;
那你可以打电话
this.table.filter()
我有一个 PrimeNg p-table,我需要根据用户设置默认过滤,所以我想我需要使用类似 let table = document.getElementById("dt");
的东西,其中 table 是 primeNg 的table 对象是这样我可以像在 html 中那样调用 table.filter(filterDefault, col.field, 'in');
。我只是不知道如何将 #dt
作为正确的类型传递到我的打字稿中,或者也许有一种更简单的方法可以使用 p-table 已有的内容来完成此操作。
<p-table #dt>
...
<tr>
<th *ngFor="let col of columns" [ngSwitch]="col.filterType" class=showOverflow pResizableColumn>
...
<p-multiSelect *ngSwitchCase="'DropDown'" [options]="masterSearchTypes" defaultLabel="All"
[(ngModel)]="filterDefault" (onChange)="dt.filter($event.value, col.field, 'in' )"></p-multiSelect>
</th>
</tr>
...
</p-table>
在你的 TS 文件中使用 @Viewchild :
import { ViewChild } from '@angular/core';
import { Table } from 'primeng/table';
@ViewChild('dt') table: Table;
那你可以打电话
this.table.filter()