Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

Show only one property but select complete object #92

Open
Mojo90 opened this issue Oct 2, 2016 · 2 comments
Open

Show only one property but select complete object #92

Mojo90 opened this issue Oct 2, 2016 · 2 comments

Comments

@Mojo90
Copy link

Mojo90 commented Oct 2, 2016

If I have the following Object:

{
    id:1,
    name: 'Audi'
}

It is possible via options="c.name for c in cars" to show the name but if I select it I need the complete Object selected as maybe some objects have the same Name I need to get the ID of the Object. How can that be achieved? (Sorry could not read out of the examples and other issues.)

Alternatively I can Imagine to show more than one property as text but how could that achieved? Already tried sth like options="c.id, c.name for c in cars" but without success.
If that is easily possible to achieve it is a great plugin even after years of creating the code base  😎!!

@NithinBiliya
Copy link

It is possible to get the 'id' of the selected object assigned to the model as -
options="c.id as c.name for c in cars"
But this will not work as expected if 'id' is a string. Then the 'id' of the selected value will be displayed as the button text.

NithinBiliya pushed a commit to NithinBiliya/angular-multiselect that referenced this issue Nov 22, 2016
…o the model value amitava82#94

Possible fix for issue - Show only one property but select complete object amitava82#92

File changed - multiselect.js

Changes made -
Added a new function - getItemLabel(items,model)
Calling the above function in function getHeaderText()
NithinBiliya pushed a commit to NithinBiliya/angular-multiselect that referenced this issue Nov 22, 2016
…o the string modal value amitava82#95

Possible fix for issue - Show only one property but select complete object amitava82#92

File changed - multiselect.js

Changes made -
Calling the function getItemLabel(items,model) in function getHeaderText()
@Mojo90
Copy link
Author

Mojo90 commented Nov 24, 2016

Okay it is not so a big problem at the moment that if it is selected than only the ID appears (you are right my IDs are strings).
But than is it possible to generate the displayed button text as Audi (1), so something like options="c.id as 'c.name (c.id)' for c in cars"? I tried that and unfortunately it does not work like that it does than print out c.name (c.id) everytime.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants