以下是您单击进行排序的列标题链接的 Razor 代码:
<th>@Html.ActionLink("Last Name", "Index", new { sortOrder = ViewBag.LNameSortParm, currentFilter = ViewBag.CurrentFilter }, new { title = "Sort by Last Name ascending" })</th>
但我希望链接旁边有一个图标,指示正在进行的排序。类似于引导字形的东西。预先感谢您的回答、意见或建议。
最佳答案
你可以尝试:
<th>@Html.ActionLink("Last Name", "Index",
new { sortOrder = ViewBag.LNameSortParm, currentFilter = ViewBag.CurrentFilter },
new { title = "Sort by Last Name ascending" })
<i class="the-icon-class"></i>
</th>
如果您需要根据排序顺序更改图标,您可以删除“className”变量并根据您的 ViewBag.LNameSortParm 为其分配一个值(我认为该变量表示升序或降序)。 所以,你会得到类似的东西:
...<i class="@className"></i>...
更新
@{
var className = "";
if(ViewBag.SortOrder.Equals("asc"))
{
className = "glyphicon glyphicon-triangle-top";
}
else
{
className = "glyphicon glyphicon-triangle-bottom";
}
}
关于c# - .NET MVC 5 C# - 将可单击图标放置在列标题旁边,用于按姓氏等对页面上的项目列表进行排序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33303737/