Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selected values in multiselect label are (null) when list of options loaded *after* bound selectedValue #725

Closed
tbertran opened this issue Aug 10, 2016 · 5 comments
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@tbertran
Copy link

Title is a bit convoluted but this plunker illustrates the problem.
Note that if selectedCars is populated before cars, it works fine.

FYI, I'm having this issue because, in my case, those two come from two different GET requests.

@michalig
Copy link

I'm not sure if this is the same issue but I have similar problem when using multiselect together with ng-translate. If I use translated string as a label, after refreshing the page (with F5) it is not displayed at all. I've tried to fix that somehow but I guess this is because ng-translate loads translation asynchronously and multiselect is rendered before it finishes.

@tbertran did you have a similar problem with multiselect?

@tbertran
Copy link
Author

tbertran commented Nov 1, 2016

I did not use it with ng-translate so I don't know.

@mozdynjr
Copy link

I've also had this problem with @angular/*=2.4.7 and primeng=^2.0.1.
But I guess it works as suppose to. If you want to assign/reference selected values to/from a collection, you first need to fetch this collection.

My case was in general like this:
There was a component with standard binding:
<p-multiSelect [options]="brandOptions" defaultLabel="All Brands" [(ngModel)]="preselectedBrands" (onChange)="onCarBrandChange($event)"></p-multiSelect>

and I was fetching options by service like so:

private prepareBrandOptions() {
        this.carService.getBrands()
            .then(brands => this.convertToOptions(this.brandOptions, brands));
    }

and at the same time doing this.restoreBrandFilter(); which actually populated this.preselectedBrands from local storage.
this.preselectedBrands was always faster than REST call from this.carService.getBrands() and as an end result I'd always got nulls as labels (but the selections in drop-down were ok).

So I've moved this.restoreBrandFilter(); simply like so

private prepareBrandOptions() {
        this.carService.getBrands()
            .then(brands => {
                this.convertToOptions(this.brandOptions, brands);
                this.restoreBrandFilter();
            });
    }

Probably could be done more intelligently, but was sufficient at that time.
Hope it helps, because the issue is not so obvious at the first sight.
It would be nice to have some warning or reminder in the docs...

@giscafer
Copy link

i got the same issue

@cagataycivici cagataycivici self-assigned this May 26, 2017
@cagataycivici cagataycivici added the Type: Bug Issue contains a bug related to a specific component. Something about the component is not working label May 26, 2017
@cagataycivici cagataycivici added this to the 4.0.2 milestone May 26, 2017
@broweratcognitecdotcom
Copy link

broweratcognitecdotcom commented Mar 16, 2018

This problem exists in version 4.1.0. We tried 5.0 also. Still a problem. Usage:

[defaultLabel]="'@cognitec/filters/SelectArrayComponent/Choose' | translate"

The default label does not change when the language option changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

6 participants