どうしようもない。jquery テンプレート プラグインを使用してテーブルを作成し、次のような応答からのデータでテーブルを埋めたいと思います。
[
[
{Row:0,Col:0},
{Row:0,Col:1},
{Row:0,Col:2},
{Row:0,Col:3},
{Row:0,Col:4},
{Row:0,Col:5},
{Row:0,Col:6}
],
[
{Row:1,Col:0},
{Row:1,Col:1},
{Row:1,Col:2},
{Row:1,Col:3},
{Row:1,Col:4},
{Row:1,Col:5},
{Row:1,Col:6}
]
]
したがって、テーブルは各行に 2 行と 7 列があるはずです。
これが私がこだわったコードです:
$('#trTemplate').tmpl(result.d).appendTo('#containerTable');
<script id="trTemplate" type="text/x-jquery-tmpl">
{{each $data}}
{{if $index < 2}}
<tr>
{{tmpl($value) "#tdTemplate"}}
</tr>
{{/if}}
{{/each}}
</script>
<script id="tdTemplate" type="text/x-jquery-tmpl">
{{each $data}}
<td>${Col}</td>
{{/each}}
</script>
<table id="containerTable">
</table>
さまざまなアプローチを試し、正常に機能するデータ ソースの外観を変更し、テンプレートなしでテーブルを構築しようとしましたが、そのようなデータ ソースを持ち、テンプレートを使用してテーブルを構築する方法を本当に知る必要がありますか? 助けてくれてありがとう。