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

    v1 QSelect cant change value with object options

    Framework
    7
    19
    5252
    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.
    • F
      folami last edited by

      <div class="col-6 q-mb-sm" >
                  
                  <q-select
                    filled
                    dense
                    options-dense
                    options-cover
                    v-model="dialog.reg.state"
                    ref="state"
                    label="Select State"
                    :options="ngstates"
                    lazy-rules
                    :rules="[ v => !!v || 'required']"
                    @input="getLga"
                  />
                </div>
      
      ngstates = [{name: 'Abuja', stateID: 1}, {name: 'Lagos', stateID: 2}]
      

      v-model value didnt change after first selection

      1 Reply Last reply Reply Quote 0
      • A
        amer1616 last edited by

        of course, will not change the value. cuz :options is used for values inside an array. not for objects inside an array. you need to make computed prop. to iterate over the objects inside ngstates , then pick up name prop from it!!

        F 1 Reply Last reply Reply Quote -1
        • F
          folami @amer1616 last edited by folami

          @amer1616 but docs says u can use objects in array with it
          What I want is, If I select Abuja vmodel prop should return the stateID 1 and Lagos… should return stateID 2
          Besides,
          I need the value for another select option like chained/dependable dropdown select

          1 Reply Last reply Reply Quote 0
          • s.molinari
            s.molinari last edited by

            Or use the option-value prop.

            Scott

            F 1 Reply Last reply Reply Quote 0
            • F
              folami last edited by

              This post is deleted!
              1 Reply Last reply Reply Quote 0
              • F
                folami @s.molinari last edited by

                @s-molinari I did but it didn’t change after the first time

                1 Reply Last reply Reply Quote 0
                • s.molinari
                  s.molinari last edited by

                  Can you explain? Here is a pen using the option-value and option-label props.

                  https://codepen.io/smolinari/pen/LvpWNx

                  Scott

                  F 2 Replies Last reply Reply Quote 0
                  • F
                    folami @s.molinari last edited by

                    This post is deleted!
                    1 Reply Last reply Reply Quote 0
                    • F
                      folami @s.molinari last edited by

                      @s-molinari thanks for your respnse, I got it fixed! I did option-value=“stateID” instead of :option-value=“opt => opt.stateID”
                      But i will love to know the difference?

                      1 Reply Last reply Reply Quote 0
                      • s.molinari
                        s.molinari last edited by

                        That arrow function allows QSelect to “dig” into the objects offered in the options array. If you had, say, names for each of the objects, then you could have used name.object-value. But, with just plain objects in the array, QSelect has to map through them. At least that is my novice explanation of what is going on. You’ll see this pattern often, when components need to dig deeper into objects in an array.

                        Scott

                        F 1 Reply Last reply Reply Quote 0
                        • F
                          folami @s.molinari last edited by folami

                          @s-molinari 🤷🏽♂
                          But thanks anyway…really appreciate

                          1 Reply Last reply Reply Quote 0
                          • B
                            bruno.ronchetti last edited by

                            Hi everyone.

                            I have been struggling with the simplest q-select for a couple of hours now, trying to select an object form an Array (I am on v.1-beta 15 - tried both Safari and Chrome.

                            The example in the docs works in the docs page, but when I put it my project it stops working, although my page contains nothing but the code from the docs. Also, and this is really puzzling, the above codepen by Scott also does not work for me.

                            Really scratching my head here.

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

                              my select
                              4713692a-fed3-40be-b087-1d66789d62e9-image.png

                              method to create custom object array for select
                              78e052ea-2db7-4745-a00e-333dd5ea541c-image.png

                              Method for filtering
                              6676c6b8-e19e-4e76-b025-13b61e4404e2-image.png

                              result
                              70661968-fa2f-4ef0-97b1-8b268afb0448-image.png

                              1 Reply Last reply Reply Quote 1
                              • s.molinari
                                s.molinari last edited by

                                @bruno-ronchetti - Please also upgrade. Beta 15 is awfully old.

                                Scott

                                1 Reply Last reply Reply Quote 0
                                • B
                                  bruno.ronchetti last edited by

                                  Thanks everyone. I have upgraded to beta 22 and it works now.

                                  I still need to click twice to get the selection (first click highlights, second selects) - is this the expected behavior?

                                  metalsadman 1 Reply Last reply Reply Quote 0
                                  • metalsadman
                                    metalsadman @bruno.ronchetti last edited by

                                    @bruno-ronchetti no it isn’t, better show your q-select definition imo.

                                    1 Reply Last reply Reply Quote 0
                                    • B
                                      bruno.ronchetti last edited by

                                      Thanks for clarifying. I have just checked the browsers:

                                      • on OSX Chrome I get the selection on first click - version 74.0.3729.131
                                      • on OSX Safari I need to click twice - version 12.1 (14607.1.40.1.4)

                                      My q-select is pretty basic:
                                      <q-select dense bottom-slots stack-label v-model="myDoc.Model" label="Model" :options="modelOptions" class="q-mt-xl" style="max-width: 600px" />

                                      1 Reply Last reply Reply Quote 0
                                      • A
                                        Agung Pratama last edited by

                                        This post is deleted!
                                        1 Reply Last reply Reply Quote 0
                                        • A
                                          Agung Pratama last edited by

                                          <q-select
                                          class=“q-mr-xs”
                                          outlined
                                          lazy-rules
                                          label=“Provinsi”
                                          option-label=“NAMA”
                                          option-value=“KODE”
                                          @change=“selectChanges”
                                          v-model=“form.provinsi”
                                          :options=“selectOptions”
                                          :rules="[val => !!val || ‘Select your Provinsi’]"
                                          />

                                          <q-input
                                          class=“q-ml-xs”
                                          outlined
                                          v-model=“form.kabkota”
                                          label=“Kab/Kota”
                                          lazy-rules
                                          />

                                          can someone help me with this??
                                          i want select bind and change function

                                          1 Reply Last reply Reply Quote 0
                                          • First post
                                            Last post