1.JS
<script src="~/Content/plugin/template/template.js"></script>
<script type="text/template" id="template_ship">
<tr οnclick="showMeas('{{cartonId}}')" data-cartonid="{{cartonId}}" data-workorderseq="{{workOrderSeq}}" data-prodseq="{{prodSeq}}">
<td><input type="checkbox" name="check-item" value="{{cartonId}}" checked="checked"></td>
<td>{{number}}</td>
<td>{{cartonId}}</td>
<td>{{prodId}}</td>
<td>{{prodName}}</td>
<td>{{prodVer}}</td>
<td>{{routeId}}</td>
<td>{{routeName}}</td>
<td>{{routeVer}}</td>
<td>{{customerId}}</td>
<td>{{gradeId}} {{gradeName}}</td>
<td>{{binId}} {{binName}}</td>
<td>{{maxQty}}</td>
<td>{{Qty}}</td>
</tr>
</script>
<script>
var model = {
number: 1,
cartonId: carton.cartonId,
prodSeq: carton.prodSeq,
prodId: carton.prodId,
prodName: carton.prodName,
prodVer: carton.prodVer,
routeId: carton.routeId,
routeName: carton.routeName,
routeVer: carton.routeVer,
gradeSeq: carton.gradeSeq,
gradeId: carton.gradeId,
gradeName: carton.gradeName,
binId: carton.binId,
binName: carton.binName,
shipId: carton.shipId,
Qty: carton.Qty,
maxQty: carton.maxQty,
workOrderSeq: carton.workOrderSeq,
workOrderId: carton.workOrderId,
workOrderType: carton.workOrderType,
customerId: carton.customerId
};
//console.log(model);
var html = "";
html = template("template_ship", model);
$("#tb_ship").append(html);
//jsonList多条赋值:
var lots = JSON.parse(response.msg);
$.each(lots, function (i, n) {
html = template("template_lot", n);
$("#tb_ship").append(html);
});
</script>
2.引用
<table class="fixTable">
<thead>
<tr>
<th style="width:2em;"><input type="checkbox" class="checkAll" name="checkAll"></th>
<th style="width:20px;">@snLang</th>
<th>@ShipIdLang</th>
<th>@CartonIdLang</th>
<th>@prodIdLang</th>
<th>@lblproductName</th>
<th>@lblproductVel</th>
<th>@lblwayCode</th>
<th>@lblwayName</th>
<th>@lblwayVel</th>
<th>@CustomerIdLang</th>
<th>@GradeLang</th>
<th>@lbldw</th>
<th>@MaxQtyLang</th>
<th>@QtyLang</th>
</tr>
</thead>
<tbody id="tb_ship">
@{
int Num = 0;
foreach (var item in Model)
{
Num++;
<tr οnclick="showMeas('@item.cartonId')" data-cartonid="@item.cartonId" data-workorderseq="@item.workOrderSeq" data-prodseq="@item.prodSeq">
<td><input type="checkbox" name="check-item" value="@item.cartonId" checked="checked"></td>
<td>@Num</td>
<td>@item.shipId</td>
<td>@item.cartonId</td>
<td>@item.prodId</td>
<td>@item.prodName</td>
<td>@item.prodVer</td>
<td>@item.routeId</td>
<td>@item.routeName</td>
<td>@item.routeVer</td>
<td>@item.customerId</td>
<td>@item.gradeId @item.gradeName</td>
<td>@item.binId @item.binName</td>
<td>@item.maxQty</td>
<td>@item.Qty</td>
</tr>
}
}
</tbody>