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

    How can I get current node and pass it as request parameter to display it child nodes using Quasar Tree lazy loading?

    Framework
    2
    2
    571
    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.
    • U
      user123 last edited by user123

      I am using Quasar Tree lazy loading to display the data like shown in image

      scn.png

      onclick of first node I am displaying child nodes from a local JSON file, now when i click on respective child node I want to display it sub childs from another JSON file by passing its parent node id.
      Here is my code

      <template>
        <q-page class="flex fixed-left">
          <q-tree
            :nodes="treeArr"
            node-key="id"
            label-key="content"
            ref="tree"
            no-connectors
            :selected.sync="selected"
            text-color="blue"
          >
          </q-tree>
         
      
        </q-page>
      </template>
      <style >
      </style>
      <script>
      
      
      
      import someJson from "./static/somejson.json";
      import datasetsJson from "./static/datasetsjson.json";
      
      
      export default {
        name: "HelloWorld",
        data() {
          return {
            tree: [],
            selected: "",
            selectedObject: null,
            json: someJson,
            djson: datasetsJson,
            newObj: [],
            treeArr: [
              {
                content: "Resources",
                children: [],
              },
            ],
          };
        },
        computed: {},
        methods: {},
          
        created() {
          this.tree = this.get_leaves()
          console.log("json", someJson);
      
         Object.keys(this.json.body.projects.projects).forEach((j) => {
      
           
       var child = { id: j, content: this.json.body.projects.projects[j].friendlyName, children: [] };
       this.treeArr[0].children.push(child);
      console.log("test", this.json.body.projects.projects[j]);
      console.log("childs", child);
      })
      
          
        },
      };
      </script>
      

      Can any one please tell me how can I get current node and pass it as request parameter to display its respective child nodes.

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

        @user123 check the events and methods section of the qtree api. selected for example emits the key, use a ref on your qtree then use one of the method getNodeByKey to get the node object.

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