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

    Q-select with hierarchical option list?

    Help
    2
    3
    424
    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.
    • CWoodman
      CWoodman last edited by

      I need a ‘combo-box’ with a tree-structured drop-down list. Is there any way to do this with q-select? I’ve built one using q-input and q-tree that works fine, but I also need autofill which is no longer supported on q-input.

      P 1 Reply Last reply Reply Quote 0
      • P
        PSTA @CWoodman last edited by

        @CWoodman
        Hi,
        you can use v-slot. Here is simple example:

        <q-select
          v-model="selectedItem"
          :options="optionsList"
          clearable
          outlined
          options-selected-class="primary"
        >
          <template v-slot:option="scope">
            <q-expansion-item
              expand-separator
              group="section"
              :default-opened="hasChild(scope)"
              header-class="text-weight-bold"
              :label="scope.opt.label"
            >
              <template v-for="child in scope.opt.children">
                <q-item
                  :key="child.value"
                  clickable
                  v-ripple
                  v-close-popup
                  @click="selectedItem = child"
                >
                  <q-item-section>
                    <q-item-label v-html="child.label"></q-item-label>
                  </q-item-section>
                </q-item>
              </template>
            </q-expansion-item>
          </template>
        </q-select>
        

        And hasChild method:

        hasChild (scope) {
          return scope.opt.children.some(c => c.value === this.selectedItem)
        }
        
        CWoodman 1 Reply Last reply Reply Quote 1
        • CWoodman
          CWoodman @PSTA last edited by

          @PSTA Perfect! Thanks. Quasar is great - I really appreciate all the work you do.

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