I need some help to render a html table using an Angular model.
First, I have a model that specifies that I need to render a table, and a list of the "questions" that needs to be shown in the table.
Data example:
{
"Id": 25546,
"questionType": "Table",
"maxRows": 2,
"maxCols": 3,
"questionsInTable": [{
"isActive": true,
"questionText": "Table Title",
"validation": "false",
"rowPosition": 1,
"colPosition": 1,
"isPrintable": true,
"Answer": null,
"Type": "Label"
}, {
"isActive": true,
"questionText": "2014",
"validation": "false",
"rowPosition": 1,
"colPosition": 2,
"isPrintable": true,
"Answer": null,
"Type": "Label"
}, {
"isActive": true,
"questionText": "2013",
"validation": "false",
"rowPosition": 1,
"colPosition": 3,
"isPrintable": true,
"Answer": null,
"Type": "Label"
}, {
"isActive": true,
"questionText": "Another description here",
"validation": "false",
"rowPosition": 2,
"colPosition": 1,
"isPrintable": true,
"Answer": null,
"Type": "Label"
}, {
"isActive": true,
"questionText": "DescFor2014",
"validation": "true",
"rowPosition": 2,
"colPosition": 2,
"isPrintable": true,
"Answer": null,
"Type": "InputText"
}, {
"isActive": true,
"questionText": "DescFor2013",
"parentQuestion": 25546,
"validation": "true",
"rowPosition": 2,
"colPosition": 3,
"isPrintable": true,
"Answer": null,
"Type": "InputText"
}]
}
Each item (or question) is providing the row and column position in the table, also the data has two items with the Max of rows and columns. I'm able to create the table using MaxRows and MaxCols data, but I'm struggling to insert the question in the correct cell.
The result should be the example above:
Render output example:
<table>
<tr>
<td>Table Title</td>
<td>2014</td>
<td>2013</td>
</tr>
<tr>
<td>Another description here</td>
<td>DescFor2014</td>
<td>DescFor2013</td>
</tr>
</table>
Is there a way to perform this?.
I'll appreciate your help, or if you could point me in the right direction.