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-tree how to get selected node on checkbox click when using tickable nodes option

    Help
    3
    5
    1268
    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.
    • H
      hpawar last edited by

      This is my Qtree element, data is an Array and the tree loads up correctly.

      <q-input v-model=“filter” stack-label=“Filter” clearable class=“q-mb-sm”/>
      <q-tree
      :nodes=“data”
      color=“secondary”
      node-key = “id”
      accordion
      ref=“tree”
      :filter=“filter”
      :ticked.sync=“ticked”
      :tick-strategy=“tickStrategy”>
      </q-tree>

      I am unable to get any event trigger on checkbox click which gives me the current node. The examples also do not show how to handle tree events. Can someone please help?

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

        You don’t have an event in your tree component. Are you using v1 or 0.17?

        Scott

        1 Reply Last reply Reply Quote 0
        • H
          hpawar last edited by

          I am using v0.17. Actually, I was able to get the checkbox click event using @update:ticked=“callback” in my tree definition shown below.

          <q-tree
          :nodes=“dataObj”
          color=“secondary”
          node-key = “id”
          accordion
          ref=“tree”
          @update:ticked=“callback”
          :filter=“filter”
          :ticked.sync=“ticked”
          :tick-strategy=“tickStrategy”
          >
          </q-tree>

          I have a follow-up question though. I want to do some operations when a is node checked and also when a node is unchecked.

          When the node is checked I get the node correctly in callback function argument and am able to carry out the operation(turn on a layer on map).
          But, when it is unchecked I do not get unchecked items in callback argument. I want to find the unchecked item so I can do the corresponding operation(turn off layer on map).

          Is there a way to get an unchecked item from Qtree?

          1 Reply Last reply Reply Quote 0
          • C
            chyde90 last edited by

            I wouldn’t do it with events.
            Maybe you could use a vue-watcher for the ticked array.

            1 Reply Last reply Reply Quote 0
            • H
              hpawar last edited by

              Yes, I understand watcher would help as I can compare new value and old value and get the unchecked items as a difference of the two. I wanted to avoid putting a watcher on ticked array as it would make the operation expensive as watcher keeps checking for every change in value. If no alternative then maybe watcher is the way.

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