primeng icon indicating copy to clipboard operation
primeng copied to clipboard

MultiSelect value support objects

Open aemaghrabi opened this issue 9 years ago • 3 comments

Hello everyone, I was thinking to share the idea of feature, in case if it's not in the plan. So I'd like to suggest that MultiSelect support for dealing with objects, I noticed that it is not have support for dealing with objects unlike Dropdown.

I was using version 2.0.0-rc.2 of PrimeNg.

aemaghrabi avatar Jan 31 '17 20:01 aemaghrabi

In the source code of multiselect component, there is the method: findLabelByValue(val: any): string { let label = null; for(let i = 0; i < this.options.length; i++) { let option = this.options[i]; if(option.value == val) { label = option.label; break; } } return label; }

I think there is a problem with the line option.value == val How can it work with object? We need to compare with a property of the object (there is no equals mehtod in javascript like in java.. :( )

ghost avatar Feb 16 '17 08:02 ghost

Having the same issue here If the value is a object it will simple return null

TakanashiOuken avatar Jun 02 '17 10:06 TakanashiOuken

I have the same issue... The MultiSelect component already has a dataKey Properties, so I change source code and it will be fine

findLabelByValue = function (val) {
        var label = null;
        for (var i = 0; i < this.options.length; i++) {
            var option = this.options[i];
            if (option.value[this.dataKey] == val[this.dataKey]) {
                label = option.label;
                break;
            }
        }
        return label;
    };

gsbybb avatar Jun 16 '17 10:06 gsbybb