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

select component needs label and value parameters #587

Closed
afilic opened this issue May 24, 2017 · 8 comments
Closed

select component needs label and value parameters #587

afilic opened this issue May 24, 2017 · 8 comments

Comments

@afilic
Copy link
Contributor

afilic commented May 24, 2017

Here is what would improove SELECT component. Now, I have to rename my fields to get this component work, but this woud be much better.

<q-select
  type="list"
  v-model="select"
  :options="selectOptions"
  label="comp_name"
  value="comp_id"
></q-select>

Thank you for this great framework.

@rstoenescu
Copy link
Member

Hi, what exactly are you looking for? Be more specific please.

@afilic
Copy link
Contributor Author

afilic commented May 24, 2017

This is from documentation example:

selectOptions: [
  {
    label: 'Google',
    value: 'goog'
  },
  {
    label: 'Facebook',
    value: 'fb'
  },
  ...
]

My data looks like this:

selectOptions: [
  {
    comp_name: 'Google',
    comp_id: 'goog'
  },
  {
    comp_name: 'Facebook',
    comp_id: 'fb'
  },
  ...
]

I don't like to rename the fields from database. Maybe I missed something?

@rstoenescu
Copy link
Member

I see now. What you can do is when you retrieve data use JS .map() to store options in the requested format.

let options = selectOptions.map(opt => ({label: opt.comp_name, value: opt.comp_id}))

@DeepaChalla
Copy link

Hi,
How can I use this for dynamic data?

@rstoenescu
Copy link
Member

@Dmedip use a Vue computed property

@DeepaChalla
Copy link

@rstoenescu Thank you but how can id to that .In data instead of passing label and value (static data) how can I pass dynamic data ?
Types:
[
{
label: 'fdf',
value: 'dfd'
}
],

@rstoenescu
Copy link
Member

@Dmedip Use a Vue computed property... :|

computed: {
  selectOptions () {
     return [ { label: this.myLabel, value: this.myLabelValue }, ... ]
  }
}

@DeepaChalla
Copy link

hi @rstoenescu Thank you so much fro your time,trying but still could not workout,can you please take a look at below code .I have two dropdowns and need to display data for dropdowns using computed.Please help.Thanks

data{
Types: [],
Operations: [],
}
computed {
}

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

No branches or pull requests

3 participants