I have a JSON data array that includes outer and inner subarrays. My goal is to loop through both levels and create a table. Below you'll find a snippet of the sample array:
{
class:'I',
subDdiv:[
{
div: 'A',
subjects:['Subject1','Subject2','Subject3']
},
{
div: 'B',
subjects:['Subject1','Subject2','Subject3']
},
]
}
{
class:'II',
subDdiv:[
{
div: 'A',
subjects:['Subject1','Subject2','Subject3']
},
{
div: 'B',
subjects:['Subject1','Subject2','Subject3']
},
]
}
My task now is to generate a table with row headings for Class and Div.
labels :['class','div']
The current code I've written isn't producing the desired outcome,
<el-table :data="array" style="width: 100%">
<el-table-column v-for="label in labels" :key="label"
:prop="label"
:label="label">
</el-table-column>
</el-table>
Note: I am utilizing the Element UI Table component -
The desired table structure can be viewed here: https://i.stack.imgur.com/Nz7H7.png
However, the resulting table looks like this:
https://i.stack.imgur.com/lzWWN.png
I need assistance in iterating through the inner subDiv array and generating the correct table layout. You can access the code box here: https://codesandbox.io/s/vigilant-wildflower-zgiq2?file=/src/App.vue