我想知道是否可以使用对象数组将某些内容过滤到表中?
我正在使用Angular 6和PrimeNG 7
我的p表如下:
<p-table #table class="ui-table ui-table-responsive" [value]="arrays" [columns]="cols" >
...
<div class="col-xl-4">
<i class="fa fa-search" style="margin:4px 4px 0 0"></i>
<input type="text" pInputText size="50" placeholder="Rechercher" (input)="table.filter($event.target.value, cols['sort'], 'contains')" style="width:auto">
</div>
...
<p-table>
我要使用 filter()而不是 globalFilter(),因为我需要指定要过滤的字段。
cols的内容是这样的:
this.cols = [
{ field: 'number', sort: 'number', header: 'The number' },
{ field: 'type', sort: 'type', header: 'The type' },
{ field: 'place', field2: 'placeName', sort: 'place.placeName', header: 'The place'},
{ field: 'city', field2: 'cityName', sort: 'city.cityName', header: 'The city' },
...
...
];
此刻我的过滤器无法正常工作。
答案 0 :(得分:1)
您没有传递col.field的列
(input)="dt.filter($event.target.value, col.field, col.filterMatchMode)"