Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

222
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda