简体   繁体   English

PrimeNg p表的类型定义

[英]Type definition for PrimeNg p-table

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"); 我有一个PrimeNg p表,我需要根据用户设置默认过滤,所以我认为我需要使用let table = document.getElementById("dt"); Where table is whatever primeNg's table object is so I can call table.filter(filterDefault, col.field, 'in'); 其中table是primeNg的表对象,因此我可以调用table.filter(filterDefault, col.field, 'in'); as is done in the html. 就像在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. 我只是不知道如何将#dt转换为我的打字稿作为正确的类型,或者也许有一种更简单的方法可以使用p表已经具有的功能。

         <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 : 在TS文件中使用@Viewchild

import { ViewChild } from '@angular/core';    
import { Table } from 'primeng/table';    

    @ViewChild('dt') table: Table;

Then you can call 那你可以打电话

 this.table.filter()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM