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

Ability to define optionValue, optionDisabled, optionGroup in Select components #4295

Closed
serlopez46 opened this issue Oct 27, 2017 · 27 comments
Assignees
Labels
Type: New Feature Issue contains a new feature or new component request
Milestone

Comments

@serlopez46
Copy link

There is no guarantee in receiving a response in GitHub Issue Tracker, If you'd like to secure our response, you may consider PrimeNG PRO Support where support is provided within 4 business hours

I'm submitting a ... (check one with "x")

[ ] bug report => Search github for a similar issue or PR before submitting
[X] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Plunkr Case
http://plnkr.co/edit/GuEdxXOOClLs2RoeExJd?p=preview

Current behavior
Field 'value' from SelectItem is set in ngModel / FormControl.
When using an object array as options (#4274) the object is set instead.

Expected behavior
Since we already have optionLabel when using an object array as options, it would be greatly appreciated if we could define an optionValue in order to select a field of the object instead of the whole object (id for example).

What is the motivation / use case for changing the behavior?
Being able to use an array of objects as options for Dropdown and similar components but still be able to set only one of the object fields as the input value.

@cagataycivici cagataycivici added the Type: New Feature Issue contains a new feature or new component request label Nov 6, 2017
@ghost
Copy link

ghost commented Feb 9, 2018

FWIW: I was able to workaround this by using/modifying the method located in ObjectUtils.

generateSelectItems(items: any[], label: string, value?: string): SelectItem[] {
    let selectItems: SelectItem[] = [];
    if(items && items.length) {
        for(let item of items) {
            selectItems.push({label: this.objectUtils.resolveFieldData(item, label), value: value ? this.objectUtils.resolveFieldData(item, value) : item});
        }
    }
    return selectItems;
}

This way you can pas in an Object[] and specify both the label and the value.

@shamoh19
Copy link

is there any option to set string to dropdown value instead of passing entire object?

@yelhouti
Copy link
Contributor

yelhouti commented Nov 9, 2018

any ETA on this, can I make a pull request to fix it? thanks in advance

@sevenposchnappi
Copy link

same issue in autocomplete

@yelhouti
Copy link
Contributor

yelhouti commented Jun 7, 2019

You can find it implemented here in the meantime, I'll try to keep my branch up to date:
https://github.com/yelhouti/primeng/releases/tag/8.0.0-rc2

@PIlepRusel
Copy link

is the new feature not yet deployed ?

@jsilveira2
Copy link

jsilveira2 commented Jul 3, 2019

Hello @yelhouti this can already be used from the version 8.0.0?

@yelhouti
Copy link
Contributor

yelhouti commented Jul 3, 2019

primeng team refused to merge my PR, so I deployed it in my fork, to use it, use this instead of the version number in your package:

"primeng": "https://github.com/yelhouti/primeng/releases/download/8.0.0-rc2/primeng-8.0.0-rc.2-SNAPSHOT.tgz",

@jsilveira2
Copy link

I do not understand, there are many issus open with this same request and several people would certainly use this feature and yet the primeng people do not give us answers or accept implementations. Why that @cagataycivici ??

@rafa-suagu
Copy link

some news @cagataycivici ?

@vishal4799
Copy link

@yelhouti, did the prime team provide any explanation while refusing your PR?

@yelhouti
Copy link
Contributor

yelhouti commented Aug 30, 2019

yes: company policy
Although the project is opensource, it is not community driven, only employees can add new features.
PS: still the best angular component library in my opinion
PS 2: even tough they don't accept them, I make a PR every now and then hopping one of them pass, a version with all my fixes is here: https://github.com/yelhouti/primeng/ check the readme for the list of fixes/features

@yelhouti
Copy link
Contributor

yelhouti commented Sep 5, 2019

@cagataycivici thanks for assigning this, you people rock!
Please check this PR: #7279
It already fixes the problem, I would gladly add some tests/documentation wherever needed

@cagataycivici cagataycivici added this to the 9.0.1 milestone Mar 9, 2020
@cagataycivici
Copy link
Member

cagataycivici commented Mar 9, 2020

PrimeReact and PrimeVue has optionValue so PrimeNG will get it in 9.0.1 as well.

Applies to Dropdown, MultiSelect, SelectButton and Listbox

@cagataycivici cagataycivici changed the title Ability to define optionValue in components like Dropdown Ability to define optionValue in Select components Mar 9, 2020
@cagataycivici cagataycivici modified the milestones: 9.0.1, 9.1.0 Mar 18, 2020
@cagataycivici
Copy link
Member

Moved to 9.1.0 as 9.0.x is for maintenance and 9.1.x is for new stuff like this, new Galleria, Virtual Scroll Tree...

@cagataycivici cagataycivici removed the Type: New Feature Issue contains a new feature or new component request label Mar 30, 2020
@cagataycivici cagataycivici added the Type: New Feature Issue contains a new feature or new component request label Mar 30, 2020
@yelhouti
Copy link
Contributor

yelhouti commented Apr 1, 2020

Any ETA for this please? just wondering to know when to upgrade my fork :) thanks

@cagataycivici cagataycivici modified the milestones: 9.1.0, 10.0.0 May 18, 2020
@cagataycivici
Copy link
Member

9.1.0 is already packed with features and enhancements and this issue deserves more attention so moving to PrimeNG 10 which is not too far away.

@dbaghel
Copy link

dbaghel commented May 23, 2020

Thanks cagataycivici,

It's a really important feature. We need to do lot of hacks to work around it. This is very basic thing missing. Looking forward to PrimNG10

@cagataycivici cagataycivici modified the milestones: 10.0.0-rc.1, 10.FUTURE, 10.0.0-rc.2, 10.0.0-rc.3, 1.0.0-rc.4 Aug 3, 2020
@cagataycivici cagataycivici modified the milestones: 10.0.0-rc.4, 10.1.0 Aug 28, 2020
@cagataycivici
Copy link
Member

Hey all, scheduled for 10.1.0, this one has high priority.

@yelhouti
Copy link
Contributor

@cagataycivici #9359

@cagataycivici cagataycivici changed the title Ability to define optionValue in Select components Ability to define optionValue, optionDisabled, optionGroup in Select components Oct 31, 2020
@gustavobmichel
Copy link

I really welcome this change. I hadn't realised that you can intercept the change by using ControlValueAccessor. So I created a small example on Stackblitz where you can see that: https://stackblitz.com/edit/primeng-autocomplete-demo-t47r9j

Maybe it'll help someone until we get this.

cagataycivici added a commit that referenced this issue Nov 2, 2020
@cagataycivici
Copy link
Member

screely-1604318223888

cagataycivici added a commit that referenced this issue Nov 2, 2020
cagataycivici added a commit that referenced this issue Nov 2, 2020
@hakansan
Copy link

hakansan commented Nov 3, 2020

we are waiting for the new version

@gustavobmichel
Copy link

@cagataycivici will the feature be available for Auto complete components as well? I saw the tagging for SelectButton, Multi select and list box. Thanks

@sserje06
Copy link

@cagataycivici I hope you are well, I am on version 10 of PrimeNG and I have tried everything that works, bring the value (id) of the object and I tried this last change that you showed in your image but it does not work, this was already released in the last version ?

@Exlord
Copy link

Exlord commented Apr 10, 2021

same here v10 but optionValue is not a valid attribute of p-dropdown ??
I even looked throw the source code and optionValue is nowhere to be found , but the docs says I can use it ???


Ok Its working in version 11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: New Feature Issue contains a new feature or new component request
Projects
None yet
Development

No branches or pull requests

17 participants