Vue-select: Support labels from nested objects

Created on 22 Mar 2018  路  5Comments  路  Source: sagalbot/vue-select

Hi,

We just had an issue where we had an object with different labels based on localisation, e.g. like this:

{ name: { en: 'test', ...} } 

The problem is that in this case we can't use a label value like name.en. Would it be possible to add support for nested object labels, e.g. using code like this: https://gist.github.com/jasonrhodes/2321581

I think the quick win is simple object nesting (dot notation), and not worrying about arrays (an extreme edge case I'd imagine)

Thoughts?

Most helpful comment

This is possible in v3:

<v-select :getOptionLabel="opt => opt.meta.label" />

All 5 comments

We ran into this issue as well since our object was similarly nested like yours. I added lodash and opened a PR for this.

https://github.com/sagalbot/vue-select/pull/499

Awesome, well done @lucidsif. So how about it @sagalbot?

@lucidsif I just tested your pull request but there are some problems. I use multiple select but when I select one option, others are muted out.

Then I inspected Select.vue an recognized that there are other

something.[this.label]

parts in the code which creates problems since label is a deep label. These parts also should be updated

This is possible in v3:

<v-select :getOptionLabel="opt => opt.meta.label" />
Was this page helpful?
0 / 5 - 0 ratings

Related issues

davidalvarezr picture davidalvarezr  路  3Comments

edalzell picture edalzell  路  3Comments

xuwenhao picture xuwenhao  路  3Comments

FrancescoMussi picture FrancescoMussi  路  3Comments

theseawolves picture theseawolves  路  4Comments