I'm currently working on a project that utilizes the dataview component from PrimeNG. I am trying to allow users to filter by multiple fields simultaneously, specifically by name and category. However, I have encountered an issue where it only filters by one field at a time.
Here is a snapshot of the complete dataview:
https://i.sstatic.net/w4Ak4.png
For example, when I select the 'Accessories' category, only products with this specific category are displayed. https://i.sstatic.net/phvd8.png
But when I try to search using the input field, it shows products from categories other than 'Accessories'. This discrepancy in applying multiple filters is my current challenge. Can you help me figure out what I might be doing wrong?
https://i.sstatic.net/GWSVA.png
Below is a snippet of my code:
<p-dataView #dv [value]="products" [paginator]="true" [rows]="9" filterBy="name,category" [sortField]="sortField" [sortOrder]="sortOrder" layout="grid">
....
<p-multiSelect [options]="listCategory" [(ngModel)]="selectedCategory (onChange)="dv.filter($event.value)" defaultLabel="Select category"> </p-multiSelect>
<span class="p-input-icon-left p-mb-2 p-mb-md-0">
<i class="pi pi-search"></i>
<input type="search" pInputText placeholder="Search by Name" (input)="dv.filter($event.target.value)">
</span>
...
</p-dataView>
I have created a stackbliz demo to showcase the issue I am facing.
- Angular Version: 11
- PrimeNG Version: 11