[英]foreach binding for only one <td> element in knockout
我在我的MVC項目之一中使用敲除綁定。
我想在單個上申請foreach綁定
<table>
<thead>
<tr>
<th>MarginType</th>
@foreach (var discountGroup in Model.CustomerDiscountGroups)
{
<th>
@discountGroup.Code
</th>
}
</tr>
</thead>
<tbody data-bind="foreach: MarginTypes">
<tr>
<td data-bind="foreach:CustomerDiscountGroups">
<span data-bind="text:Code"> </span>
</td>
</tr>
</tbody>
我要重復第二次td,沒有customerdiscountgroups。
我認為您不需要每個,也不需要內在的<TH>
<tr>
<th>MarginType</th>
<th>
@Model.CustomerDiscountGroups.First().Code
</th>
</tr>
我不確定我是否正確理解您的意思,但是如果您要為CustomerDiscountGroups
每個項目重復<td>
,則可以將foreach
放在<tr>
。
<tbody data-bind="foreach: MarginTypes">
<tr data-bind="foreach: CustomerDiscountGroups">
<td>
<span data-bind="text:Code"> </span>
</td>
</tr>
</tbody>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.