I want to create a tree structure table.
I have a json array of strings. One line may have other child lines.
[ { "Name": "Row 1", "Depth": 1, "Rows": [{ "Name": "Row 1.1", "Depth": 2, "Rows": [] }] }, { "Name":" Row 2", "Depth": 1, "Rows": [] } ]
The template that I have for the line (which does not work) is as follows:
<script type="text/html" id="row-template"> <tr> {{ for(var i = 1; i<= Depth; i++) { }} <td class='col'></td> {{/for}} <td data-bind="text: Name"></td> </tr> </script>
Is there a way to use duplicate statements inside a knockout pattern, so I can add extra n columns that I need for each row?
source share