build table with jquery template plugin

http://stackoverflow.com/questions/5051082/build-table-with-jquery-template-plugin

by rniemeyer

HTML

<script src="http://knockoutjs.com/downloads/jquery.tmpl.min.js"></script>

<script id="trTemplate" type="text/x-jquery-tmpl">
            <tr>
                {{each $data}}
                    <td>${Col}</td>
                {{/each}}
            </tr>
</script>


<table id="containerTable">
</table>

JavaScript

var data = [
     [
        {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}
     ]
];

$('#trTemplate').tmpl(data).appendTo('#containerTable');