0
我正在研究一個應用程序,其中的某些其他數據與具有使用基本js綁定的數據的html表中的其他數據相關聯。下面的代碼不會在部分中顯示產品,但每個產品都顯示爲不同的產品,儘管它們是相同的。在html/knockout js中爲表格中的每個不同項目創建部分
HTML
<table class="productTable" data-bind="visible: !loading()">
<thead>
<tr>
<th>Product</th>
<th>Term</th>
<th>Location</th>
<th>Pipeline</th>
<th>Bid C/P</th>
<th>Bid Volume</th>
<th>Index</th>
<th>Bid</th>
<th>Offer</th>
<th>Offer Volume</th>
<th>Offer C/P</th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</thead>
<tbody data-bind="foreach: canadiancrudes" >
<tr >
<td data-bind="text:Product"></td>
</tr>
<tr>
<td data-bind="text: Term"></td>
<td data-bind="text: Location"></td>
<td data-bind="text: Pipeline"></td>
<td data-bind="text: BidCP"></td>
<td data-bind="text: BidVolume"></td>
<td data-bind="text: Index"></td>
<td>
<input type="text" id="txbReadBid" data-bind="value: Bid" /></td>
<td>
<input type="text" id="txbReadOffer" data-bind="value: Offer" /></td>
<td data-bind="text: OfferVolume"></td>
<td data-bind="text: OfferCP"></td>
<td></td>
<td>
<a href="#" title="Edit" data-bind="click: $root.edit">
<img src= '@Url.Content("~/Images/edit.png")' /></a></td>
<td><a href="#" title="Delete" data-bind="click: $root.remove">
<img src= '@Url.Content("~/Images/delete.png")' /></a></td>
<td>
<a href="#" title="Copy" data-bind="click: $root.copy">
<img src= '@Url.Content("~/Images/add.png")' /></a>
</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>Product</th>
<th>Term</th>
<th>Location</th>
<th>Pipeline</th>
<th>Bid C/P</th>
<th>Bid Volume</th>
<th>Index</th>
<th>Bid</th>
<th>Offer</th>
<th>Offer Volume</th>
<th>Offer C/P</th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
</tfoot>
</table>
從下面的截圖可以看到,我有不同的其他領域類似的產品,但它們不是切片。現在我想爲每個產品都設置一個部分,比如Product C5在表格中有四個條目,所以我希望所有這些條目都在一個部分中,並且每當我點擊右側的'+'圖像時,它會添加一個具有相同產品的行與'+'圖像相關聯,我試圖將其添加到相同的產品部分。