I am currently working with an array of objects where each object contains another array.
panels = [{
Id: "26cfdb68-ef69-4df0-b4dc-5b9c6501b0dd",
Name: "Celiac test",
Tests: [{
Id: "e2bb4607-c227-4483-a3e9-55c1bc5a6781",
Name: "test 1 (DGP) IgG"
},
{
Id: "e2bb4607-c227-4483-a3e9-55c1bc5a6781",
Name: "test 2 (DGP) IgG"
},
{
Id: "e2bb4607-c227-4483-a3e9-55c1bc5a6781",
Name: "test 3 (DGP) IgG"
}
]
}],
My goal is to create a bootstrap accordion with checkboxes based on this data structure.
The design requires a main checkbox for the object, followed by individual checkboxes for the array elements.
When I click the main Panel checkbox, it should also select all the Tests checkboxes and store the panel object in a variable called selectedPanel. Deselecting the main Panel should unselect all Tests checkboxes as well.
While I have accomplished this functionality, the main challenge lies in removing a Test checkbox from selectedPanel and updating its length when deselected.
If anyone can provide assistance with this issue, it would be greatly appreciated.
I have created a demo on Stackblitz: