I am facing an issue with my array structure, it looks like this,
[
[
"Show/Hide",
"P000",
"MAX-CT05 FVM2-",
"S",
1532,
-9.5929406005,
null,
null,
null,
"Open",
null,
"",
null
],
[
"",
"P000-000",
"MAX-CT05 FVM2-",
"S",
22,
-9.985,
null,
null,
null,
"Open",
null,
null,
"P000"
],
...
]
Another array I have is structured differently, like so,
[
{
"header": true
},
{
"pk": "P000",
"nest": 0
},
{
"pk": "P000-000",
"nest": 1
},
...
]
The second array defines parent-child relationships based on the value of nest
. If nest
is zero, it's a parent; if it's one, it's a child. My goal is to create a new grouped array of children indexed by their parent's index. Here's what I'm trying to achieve,
[
0: [
[
"",
"P000-000",
"MAX-CT05 FVM2-",
"S",
22,
-9.985,
null,
null,
null,
"Open",
null,
null,
"P000"
],
...
],
1: [
[
"",
"P001-000",
"MAX-CT07 TYM2-",
"S",
99,
-1.865,
null,
null,
null,
"Open",
null,
"98.8mm JPM PB",
"P001"
],
...
]
]
I attempted to implement this logic in my code but encountered this error:
Cannot set properties of undefined (setting 'parent_1]')