0
我添加的自舉數據表到我的項目,其中有一些最低要求。工作構建表:http://legacy.datatables.net/usage/引導數據表:使用迭代器
這工作得很好用下面的代碼:
<table id="management" class="table table-bordered table-hover" >
<thead>
<tr>
<th class="col-md-3">Serial</th>
<th class="col-md-2">Tienda</th>
<th class="col-md-1">Precio</th>
<th class="col-md-2">Estado</th>
<th class="col-md-1">Update</th>
</tr>
</thead>
<tbody>
<tr>
<td class="col-md-3">
<div>Column1</div>
</td>
<td class="col-md-2">
<div>Column2</div>
</td>
<td class="col-md-1">
<div>Column3</div>
</td>
<td class="col-md-2">
<div>Column4</div>
</td>
<td class="col-md-1">
<div>Column5</div>
</td>
</tr>
@foreach (var item in Model)
{
<tr>
<td hidden >
<form id="@(String.Format("{0}{1}","form",item.Id))" asp-action="Management" asp-route-id="@item.Id" method="post">
</form>
</td>
<td class="col-md-3">
<input form="@(String.Format("{0}{1}","form",item.Id))" type="hidden" asp-for="@item.Id" />
<div class="form-group" form="@(String.Format("{0}{1}","form",item.Id))">
<div>
<input form="@(String.Format("{0}{1}","form",item.Id))" asp-for="@item.MchName" name="MchName" readonly class="form-control" />
<span asp-validation-for="@item.MchName" class="text-danger"></span>
</div>
</div>
</td>
<td class="col-md-2">
<div class="form-group" form="@(String.Format("{0}{1}","form",item.Id))">
<div>
<select asp-for="@item.StoreID" name="StoreID" class="form-control" asp-items="ViewBag.StoreID" form="@(String.Format("{0}{1}","form",item.Id))"></select>
<span asp-validation-for="@item.StoreID" class="text-danger"></span>
</div>
</div>
</td>
<td class="col-md-1">
<div class="form-group" form="@(String.Format("{0}{1}","form",item.Id))">
<div>
<input type="number" max="10" min="0" step=".5" asp-for="@item.PUnit" name="PUnit" class="form-control" form="@(String.Format("{0}{1}","form",item.Id))" />
<span asp-validation-for="@item.PUnit" class="text-danger"></span>
</div>
</div>
</td>
<td class="col-md-2">
<div class="form-group" form="@(String.Format("{0}{1}","form",item.Id))">
<div>
<select name="Status" asp-for="@item.MachineStatus" class="form-control" form="@(String.Format("{0}{1}","form",item.Id))">
<option value="0">Operativo</option>
<option value="1">Nuevo Item</option>
<option value="2">Reparación</option>
</select>
<span asp-validation-for="@item.MachineStatus" class="text-danger"></span>
</div>
</div>
</td>
<td class="col-md-1">
<input form="@(String.Format("{0}{1}","form",item.Id))" id="submit-data" type="submit" value="Update" class="btn btn-default" />
</td>
</tr>}
</tbody>
</table>
之所以能夠正常工作,是因爲我在<tbody>
上手動添加了一行記錄,並且與此一致,表格符合要求,但當然不能這樣。
當我刪除該行並讓表迭代器構造:
@foreach (var item in Model)
我收到以下錯誤:
問:是否有可能使用像我打算的Bootstrap Datatable?出現這些錯誤是因爲它沒有考慮用迭代器構建的行。
也許它不被支持。