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

219
Views
I can't add child elements as treetable dynamic

I want to add elements to treetable dynamically.but I can't combine arrays when merging.

const nodes=([]);
const children=([])

then I add an element to the nodes array

 nodes.push({
        key: keyIndex.value,
        data:{
          "name":newExplanation.value,
          "size":"100kb",
          "type":"Folder"

        },
      })

This is how I push on my second string

children.push({
            children:[
              {
                key: tempRoot.value + '-0' ,
                data: {
                  "name": Explanation.value,
                  "size": "100kb",
                  "type": "Folder"

                }
              }]

          })

then I want to add a child node element under this element and I want to combine these two arrays. But they don't get together, they seem like two separate elements in an array. for example nodes[0:{first element}, {second element]

Here's how I do the merge

let r = nodes.concat({...children})
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

What if you push in children in the same way as in nodes like this

children.push({
    key: tempRoot.value + '-0' ,
    data: {
        "name": Explanation.value,
        "size": "100kb",
        "type": "Folder"
    }
});

and then concatenate like this

let r = nodes.concat(children);
over 4 years ago · Santiago Trujillo Report

0

Try like following snippet:

const nodes=([]);
const children=([])

nodes.push({key: 1, data:{"name":11, "size":"100kb", "type":"Folder"},})

children.push({children:[{key: 12 + '-0', data: {"name": 123, "size": "100kb", "type": "Folder"}}]})
          
let r = nodes.concat(...children[0].children)
console.log(r)

over 4 years ago · Santiago Trujillo 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!