我必须将项目 ID 作为呈现的 <Tr> 的 ID 添加到我的 WebGrid 中的方法是什么

what are the approachies i have to ad the item id as the id of the rendered <Tr> inside my WebGrid

我正在开发一个 asp.net MVC web 应用程序,在我看来,我有一个 webgrid 如下:-

@model  T.ViewModels.GridList<T.Models.Resources>
var gridcolumns = new List<WebGridColumn>();
gridcolumns.Add(new WebGridColumn()
      {

        CanSort = false,
        Format =
          (item) =>
             {
               var banner = item.Value as T.Models.Resources;
               return Ajax.ActionLink("Delete", "Delete", banner.Technology.TechnologyType.Name, new { id = banner.TechnologyID },
new AjaxOptions
{
    Confirm = "Are You sure You want to delete (" + banner.Technology.Tag.ToString() + ")",
    HttpMethod = "Post",

    OnSuccess = "deletionconfirmation",
    OnFailure = "deletionerror"
});
                    }

        });
            var grid = new WebGrid(
                        canPage: true,
                        rowsPerPage: Model.PageSize,
                        canSort: true,
                        ajaxUpdateContainerId: "grid");

            grid.Bind(Model.Content, rowCount: Model.TotalRecords, autoSortAndPage: false);
            grid.Pager(WebGridPagerModes.All);

            @grid.GetHtml(htmlAttributes: new { id = "grid" },   // id for ajaxUpdateContainerId parameter
            fillEmptyRows: false,
            tableStyle: "table table-bordered table-hover",
            mode: WebGridPagerModes.All,
            columns: gridcolumns

            );

现在网络网格将生成一个 HTML table 行。如我上面的示例代码所示,我有一个 Ajax.ActionLink 来删除一行,并且我正在传递项目 ID。然后在 OnSuccess = "deletionconfirmation" 函数中我将删除相关行,如下所示:-

function deletionconfirmation(data)
{
    if (data.IsSuccess == "reload") {
        location.reload();
    }
    if (data.IsSuccess == "True") {
        $('#' + data.id).remove();

        $.fn.jAlert({
            'title': 'Deletion Confirmation',
            'message': data.description   +  ' deleted successfully',
            'theme': 'success',
            'clickAnywhere': false
        });
    }

但我的问题是如何将项目 ID 添加到 WebGrid 中作为生成行的 ID?

deletionconfirmation 方法中的 this 表达式将为您提供用户单击以启动 ajax 调用的锚标记 HTML 元素。您可以使用 jQuery closest 方法来获取它的外部 TR。

function deletionconfirmation(data) {

    var $tr = $(this).closest("tr");

    //Do your if conditions to check the data property to determine what to do next.

    $tr.fadeOut(400);

}