Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

99
Views
How to add specific data to nested children in he-tree-vue javascript library

The following is an example of an array of objects, where the data consists of four levels of nested data.

here I display the children's data on the he-tree-vue when the user presses the toggle on a specific element then makes a request to the api, so later the data is added to a certain array value based on existing data to be displayed as child data.

[{ // class
      ClassID:"0ede11",
      Title:"Mandiri",
      children:[{ // course/subject
            CourseID:"0ec2",
            Title:"Math",
            children:[ // chapter
               {
                  ChapterId:"0ss23",
                  Title:"Test test",
               },
          {
                  ChapterId:"0ss23",
                  Title:"Test test"
               },
          {
                  ChapterId:"0se22",
                  Title:"Test test"
               },
        ]      
      },
      {
            CourseID:"rere43",
            Title:"History",
            children:[
               {
                  ChapterId:"0sse56",
                  Title:"Test test",
               },
          {
                  ChapterId:"0ss2qqq3",
                  Title:"Test test"
               },
          {
                  ChapterId:"0sefg22",
                  Title:"Test test"
               },
        ]      
      }
   ]
}]

how do I add data to specific children, here I use the he-tree-vue library to display a data tree that can be dragged.

now i use the following code, but it only works on the first child only.

getChapter(id, index) {
    this.API.getChapter(id, (data) => {
      console.log(data);
      // I'm still confused in this part, how to dynamically add data to specific child data at each level 
      const newData = [...this.playlistData];
      newData[index].children[index].children = data;
      this.playlistData = newData;
    },
    (err) => {
      console.log(err);
    });
 }

Thank you.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Ok solved, I just need to save each index on each level then use it when going to add data.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!