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 tick all nodes

    Help
    3
    4
    110
    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.
    • S
      ScoutKirkOlson last edited by

      Is there a way to tick all nodes in a Q-Tree, either by a directive or programmatically?
      I want all nodes to be initially ticked when I show the component.
      My nodes are dynamically loaded through a computed vue property, so I can’t simply set the ticked.sync prop.

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

        You could do it in your computed props setter.

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

          This is how I do it:

          <q-tree
              :nodes="nodes"
              :ticked.sync="tickedNodeKeys"
              node-key="key"
             ...
           />
          
          data() {
             return {
                tickedNodeKeys: [],
                allNodeKeys: []
             }
          },
          computed() {
             nodes() {
                // !!! while generating the nodes, I collect the keys and write them into this.allNodeKeys
                // if you want to tick everything initially, you can set this.tickedNodeKeys here right away
                // return generated nodes
             }
          },
          methods: {
             tickAll() {
                this.tickedNodeKeys = [...this.allNodeKeys];
              }
          }
          

          I hope it helps

          S 1 Reply Last reply Reply Quote 0
          • S
            ScoutKirkOlson @chyde90 last edited by

            @chyde90 works like a charm, thanks!

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