No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Qselect array structure

    Framework
    2
    2
    806
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • N
      neomobil last edited by

      Hi everybody!
      Is there a simple way to get work Qselect with an array like this,
      [ {id: 1, title: ‘title1’}, {id: 2, title: ‘title2’} ]
      and not the suggested one
      [
      {
      label: ‘Google’,
      value: ‘goog’
      },
      {
      label: ‘Facebook’,
      value: ‘fb’
      }
      ]

      1 Reply Last reply Reply Quote 0
      • benoitranque
        benoitranque last edited by

        Hi. No.

        You should modify your array for displaying in the q-select
        Note: value does not have to be a string. So considering your example and assuming you want the whole object as the value:

        data () {
          return {
            options: [].// formated options array
            value: [] // array of selected values
          }
        },
        mounted () {
          // get options during mouted function
          axios.get('/path')
            .then(response => {
             this.options = response.data.map(item => {
                return {
                  label: item.title,
                  value: item  // assign whole object as value. Could be anything
                }
              })
            })
        }
        
        1 Reply Last reply Reply Quote 2
        • First post
          Last post