【问题标题】:PrimeNG filter using array object使用数组对象的 PrimeNG 过滤器
【发布时间】:2019-08-11 05:23:10
【问题描述】:

我想知道是否可以使用对象数组将某些内容过滤到表格中?

我正在使用 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' },
  ...
  ...
];

目前我的过滤器不起作用..

【问题讨论】:

    标签: angular typescript filter primeng primeng-turbotable


    【解决方案1】:

    你没有传递 col.field 的列传递你的列

    (input)="dt.filter($event.target.value, col.field, col.filterMatchMode)"
    

    【讨论】:

      猜你喜欢
      • 2023-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-22
      • 2021-02-03
      • 2017-10-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多