4
我想創建一個樹形結構表。我有json的行數組。一行可以有其他子行。Jquery Knockout for/while循環模板
[
{
"Name": "Row 1",
"Depth": 1,
"Rows": [{ "Name": "Row 1.1", "Depth": 2, "Rows": [] }]
},
{
"Name":" Row 2",
"Depth": 1,
"Rows": []
}
]
模板我有一個行(不工作)看起來是這樣的:
<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>
是否有利用基因敲除模板中重複的語句,所以我可以添加額外的n
的任何方式我需要每列的列?
有你看着http://stackoverflow.com/questions/11509324/recursive-tr-with-knockout-js-and-jquery-template?rq=1似乎與你想要的相似。 –
解決了嵌套模板問題,但不是我需要的:( – Catalin