在 asp.net mvc 应用程序中,我使用 jquery 上下文菜单库。这是我的代码:
$.contextMenu({
selector: '.context-menu',
build: function ($trigger, e) {
return {
callback: function (key, options) {
},
items: {
}
};
}
});
删除了额外的代码。
这是我的看法:
<table class="table table-bordered">
<thead>
<tr>
<th>
@Html.ActionLink("Марка", "Index", new { sortOrder = ViewBag.MarkSort })
</th>
<th>Модель</th>
<th>
@Html.ActionLink("Цена", "Index", new { sortOrder = ViewBag.PriceSort })
</th>
<th>Количество на складе</th>
</tr>
</thead>
<tbody class="context-menu">
@foreach (var item in Model)
{
@Html.Partial("_Car", item)
}
</tbody>
</table>
这是我的局部视图,它被调用来渲染表中的行:
@model AutoStore.Domain.Core.Car
<tr id="@Model.Id">
<td>@Html.DisplayFor(item => item.Mark.MarkName)</td>
<td>@Html.DisplayFor(item => item.CarModel.ModelName)</td>
<td>@Html.DisplayFor(item => item.Price)</td>
<td>@Html.DisplayFor(item => item.Count)</td>
</tr>
部分可见,我挂断了 tr (字符串)上的记录 ID。所以。当我调用上下文菜单进行进一步编辑时,我想考虑我单击的行的 id。
我找不到如何提取特定行的特定 ID。但是有一个选项可以拉出我单击的 id tds,但在这种情况下,ids 将不得不挂在所有 tds 上,我还不想这样做,请告诉我如何拉出整行的id。PS。如果点击的 td 的 id 是使用 build 中的 e 参数提取的e.target.id
1 个回答