0
如何從我的表中實際檢索選定行的主鍵(model.ID)。如果選擇單個行,我想使相同的情況按鈕A B C被啓用,但如果選擇了多個行,只有按鈕c被啓用,則a和b將被禁用。 我在下面貼了我的編碼。如何從選擇行中檢索數據庫數據
$(document).ready(function() {
var table = $('#LineTables').DataTable();
$('#LineTables tbody').on('click', 'tr', function() {
if ($(this).hasClass('selected')) {
$(this).removeClass('selected');
}
else {
table.$('tr.selected').removeClass('selected');
$(this).addClass('selected');
}
});
});
});
<table id="LineTables" class="display dataTable">
<thead>
<tr>
<th>@Html.DisplayNameFor(model => model.Priority)</th>
<th>@Html.DisplayNameFor(model => model.ProductionOrderNumber)</th>
<th>@Html.DisplayNameFor(model => model.SalesOrder.Product.ProductGroup.Name)</th>
<th>@Html.DisplayNameFor(model => model.SalesOrder.Product.ProductName)</th>
<th>@Html.DisplayNameFor(model => model.Quantity)</th>
<th>@Html.DisplayNameFor(model => model.SalesOrder.Product.Pole)</th>
<th>@Html.DisplayNameFor(model => model.SalesOrder.Product.Amperage)</th>
<th>@Html.DisplayNameFor(model => model.SalesOrder.SalesOrderType1.Name)</th>
<th>@Html.DisplayNameFor(model => model.SalesOrder.Market)</th>
<th>@Html.DisplayNameFor(model => model.ProductionOrderStatu.Name)</th>
<th>@Html.DisplayNameFor(model => model.SalesOrder.SalesOrderNumber)</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>@Html.DisplayFor(modelItem => item.Priority)</td>
<td>@Html.DisplayFor(modelItem => item.ProductionOrderNumber)</td>
<td>@Html.DisplayFor(modelItem => item.SalesOrder.Product.ProductGroup.Name)</td>
<td>@Html.DisplayFor(modelItem => item.SalesOrder.Product.ProductName)</td>
<td>@Html.DisplayFor(modelItem => item.Quantity)</td>
<td>@Html.DisplayFor(modelItem => item.SalesOrder.Product.Pole)</td>
<td>@Html.DisplayFor(modelItem => item.SalesOrder.Product.Amperage)</td>
<td>@Html.DisplayFor(modelItem => item.SalesOrder.SalesOrderType1.Name)</td>
<td>@Html.DisplayFor(modelItem => item.SalesOrder.Market)</td>
<td>@Html.DisplayFor(modelItem => item.ProductionOrderStatu.Name)</td>
<td>@Html.DisplayFor(modelItem => item.SalesOrder.SalesOrderNumber)</td>
<td>
@Html.ActionLink("New Barcode", "Barcode", new { id = item.ID }, new { @class = "barcode btnic btnicon" })
</td>
</tr>
} </tbody>
</table>
@Html.ActionLink("A", "Index", "A", .......... , new { @class = "btn btn-default btn-ms" })
@Html.ActionLink("B", "Index", "B", .......... , new { @class = "btn btn-default btn-ms" })
@Html.ActionLink("C", "Index", "C", .......... , new { @class = "btn btn-default btn-ms" })
你想在哪裏找回ID?在行點擊事件? –
@StephenMuecke是的。 – user3758689