Is it feasible to utilize an array of objects for filtering data in a table?
I'm currently using Angular 6 and PrimeNG 7.
This is how my p-table appears:
<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="Search" (input)="table.filter($event.target.value, cols['sort'], 'contains')" style="width:auto">
</div>
...
<p-table>
I prefer using filter() over globalFilter() as I need to specify the field for filtering.
The columns in my table are defined as follows:
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' },
...
...
];
Unfortunately, my current filter implementation is not functioning correctly.