Thanks Johan for the clarification and pointer.
May I ask if the referenced approach also works for deeper groupings?
In the example you gave, both "Top" and "Ones" are static.
The intent is for:
- "Top" (...Top 2, Top 3... etc) to be dynamic resourceStore items,
- "Ones" & "Others" to be static groups under all Tops for each resource item.
- children to be resource store item groups under Ones & Others associated filtered to it's respective "Top" resource.
My attempts to reshape the data object using links (grouping resource leaf nodes under resource parents), throws an error when nested under anything other than a static parent.
I've included a contrived 2-level snippet below.
let leafNodes = resourceStoreInstance.leaves.map(l => l.link());
let parentNodes = leafNodes.filter(l => l.resourceType == 'parent');
let childNodes = leafNodes.filter(l => l.resourceType == 'child');
let newStructureItem = parentNodes.map(p =>{
p.children = childNodes.filter(c => c.parentId == p.parentId);
return p
})
Error:
Thanks!