如何在 NonFactors.Mvc.Grid 行上创建下拉列表?

问题描述 投票:0回答:1

我想在网格的每一行上创建一个下拉菜单,如图所示。但是,操作链接未以正确的方式呈现。我能做什么? 在此输入图片描述

这就是我尝试过的方法:

@(
                Html.Grid(Model).Build(columns =>
                    {
                        columns.Add(m => m.ProjectName).Titled("Project");
                        columns.Add(m => m.DocumentName).Titled("Document Name");
                        columns.Add(m => m.DocumentType).Titled("Document Type");
                        columns.Add(m => m.DocumentSection).Titled("Document Section");
                        columns.Add(m => Html.ActionLink(" View More", "ViewMore", "Documents", new { id = m.DocumentID }, new { @class = "btn btn-warning" }));
                        columns.Add(m => Html.ActionLink(" Download", "DownloadFiles", "Documents", new { id = m.DocumentName }, new { @class = "btn btn-primary" }));
                        **columns.Add(m => Html.ActionLink(" Back to Project", "Index", "ProjectDetails", new { id = m.ProjectNumber }, new { @class = "btn btn-secondary" }));
                        columns.Add(m => $"<div class=\"dropdown\"><a class=\"btn btn-secondary dropdown-toggle\" href=\"#\" role=\"button\" id=\"dropdownMenuLink\" data-bs-toggle=\"dropdown\" aria-expanded=\"false\">Actions</a><ul class=\"dropdown-menu\" aria-labelledby=\"dropdownMenuLink\"><li><a class=\"dropdown-item\" href=\"#\">{Html.ActionLink(" View More", "ViewMore", "Documents", new { id = m.DocumentID }, new { @class = "btn btn-warning" })}</a></li><li><a class=\"dropdown-item\" href=\"#\">{Html.ActionLink(" Download", "DownloadFiles", "Documents", new { id = m.DocumentName }, new { @class = "btn btn-primary" })} </a></li> <li><a class=\"dropdown-item\" href=\"#\">{Html.ActionLink(" Back to Project", "Index", "ProjectDetails", new { id = m.ProjectNumber }, new { @class = "btn btn-secondary" })}</a></li></ul></div>").Encoded(false);**
                    }).Pageable(pager =>
                    {
                        pager.PageSizes = new Dictionary<Int32, String> { { 0, "All" }, { 5, "5" }, { 10, "10" } };
                        pager.ShowPageSizes = true;
                        pager.CurrentPage = 1;
                        pager.RowsPerPage = 5;
                    })
                    )
drop-down-menu bootstrap-5 nonfactors-mvc-grid
1个回答
0
投票

尝试使用 Url.Action 创建锚标记,例如

columns.Add(m =>  $"<a href=\"{Url.Action("Action", "Controller", new { id = m.Id })}\" class=\"fas fa-pencil-alt pe-2 pb-2 text-decoration-none\" title=\"Edit '{m.Name}'\"></a>" ).Encoded(false);
© www.soinside.com 2019 - 2024. All rights reserved.