Primeng - Search multiple fields in Picklist

Asked

Viewed 154 times

0

I’m using Picklist on an Angular 7 app. In Picklist, I need to search more than one field displayed in the container.

On their website (Primeng) there is an example: Picklisttutorial On the tag, there’s a field called filterBy="Brand" where I place the field to be filtered, but need to inform more fields in this part.

I tried to do so filterBy="Brand, year, color", but only takes the first field to search.

Code of the Component.html.ts

<p-pickList [source]="sourceCars" [target]="targetCars" sourceHeader="Available" targetHeader="Selected" [responsive]="true" filterBy="brand" 
        dragdrop="true" sourceFilterPlaceholder="Search by brand" targetFilterPlaceholder="Search by brand" [sourceStyle]="{'height':'300px'}" [targetStyle]="{'height':'300px'}">
    <ng-template let-car pTemplate="item">
        <div class="ui-helper-clearfix">
            <img src="assets/showcase/images/demo/car/{{car.brand}}.png" style="display:inline-block;margin:2px 0 2px 2px" width="48">
            <div style="font-size:14px;float:right;margin:15px 5px 0 0">{{car.brand}} - {{car.year}} - {{car.color}}</div>
        </div>
    </ng-template>
</p-pickList>

Code Component.ts

export class PickListDemo {

    sourceCars: Car[];

    targetCars: Car[];

    constructor(private carService: CarService) { }

    ngOnInit() {
        this.carService.getCarsSmall().then(cars => this.sourceCars = cars);
        this.targetCars = [];
    }
}
  • 1

    Put the full code.

  • I edited the question by adding the code there @Isaíasdelimacoelho

  • I looked in their repository and really bugged, https://github.com/primefaces/primeng/issues/7121 you can follow this site and see if it has any time. but unfortunately it will not be with this Component that will achieve.

  • @Isaíasdelimacoelho, I removed the spaces I had, and it worked the filter! Eduardovargas gave the solution.

1 answer

2


Does without spaces: filterBy="brand,year,color"

  • Thanks @Eduardovargas, it worked!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.