I have a PrimeNg p-table that I need to setup default filtering based on the user so I think I need to use something like let table = document.getElementById("dt");
Where table is whatever primeNg's table object is so I can call table.filter(filterDefault, col.field, 'in');
as is done in the html. I just don't know how to get the #dt
over to my typescript as the correct type or maybe there is an easier way to do this using what the p-table already has.
<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>
Use @Viewchild in your TS file :
import { ViewChild } from '@angular/core';
import { Table } from 'primeng/table';
@ViewChild('dt') table: Table;
Then you can call
this.table.filter()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With