Dropdown filtering
-
- Posts: 1
- Joined: 07 Aug 2019, 10:18
How to add custom filtering do p-dropdown. I want matching x or y if i have in input "x y".
-
- Posts: 449
- Joined: 08 Aug 2018, 14:09
Hi,maciej1234567 wrote: ↑07 Aug 2019, 10:20How to add custom filtering do p-dropdown. I want matching x or y if i have in input "x y".
Sorry, i couldn't understand, can you be more spesific?
Best Regards.
-
- Posts: 2
- Joined: 08 Aug 2019, 16:10
Hi,
if I understand what you want,
add filterBy="x, y"
from doc -> "labelBy string label When the filter is enabled, filterBy decides in which field or fields (separated by a comma) to search."
if I understand what you want,
add filterBy="x, y"
from doc -> "labelBy string label When the filter is enabled, filterBy decides in which field or fields (separated by a comma) to search."
In this case you proabbly need to do your own filter.
Try autocomplete advanced: https://www.primefaces.org/primeng/#/autocomplete
component.html
component.ts
component.service.ts
This is kinda you want but... if you want for multiple spaces, or there is no space, you have to control that, this is an example only
Try autocomplete advanced: https://www.primefaces.org/primeng/#/autocomplete
component.html
Code: Select all
<div class="p-grid">
<div class="p-col-1">
Address 1
</div>
<div class="p-col-3">
<p-autoComplete
[(ngModel)]="address1"
[suggestions]="streetStringList"
(completeMethod)="searchAddress($event)"
[dropdown]="true"></p-autoComplete>
</div>
</div>
Code: Select all
searchAddress(event) {
this.streetStringList = this.someService.getFilteredStreets(event.query);
}
Code: Select all
getFilteredStreets(street: string): string [] {
let separatedBySpace: string[] = street.split(' ');
return this.streetStringList.filter(
(element: string) => {
return element.match(new RegExp(separatedBySpace[0], 'gi')); // global, ignoreCase, no accent ignore
}
).filter(
(element: string) => {
return element.match(new RegExp(separatedBySpace[1], 'gi')); // global, ignoreCase, no accent ignore
}
);
}
maciej1234567 wrote: ↑07 Aug 2019, 10:20How to add custom filtering do p-dropdown. I want matching x or y if i have in input "x y".
I'm in need of a solution for this too.
In my case I need the filter to work like this:
This is the label: 98.765.543/0001-00
Input in filter: 98.7 (successfully found)
Input in filter: 987 (not found)
I need it to be found successfully in both cases
-
- Information
-
Who is online
Users browsing this forum: No registered users and 22 guests