MVC3 中单个 MvcContrib.Grid 列中的多个 Html.ActionLink()
我正在尝试用正确的语法来实现以下目标——或者至少找出它是否可行或者是否有更好的替代解决方案。
好的,开箱即用,当您使用 ASP.Net MVC3 下的列表脚手架生成强类型视图时,您会得到一个简单的表,其中有一列,其中有两个或三个 Html.ActionLink() 项,表示常见操作,如下所示: 编辑|详情 |删除
我想使用 MvcContrib 网格并执行相同的操作,但我无法找出使其工作的正确语法。到目前为止,在我的 Index.cshtml 中,我有以下代码片段:
@(
Html.Grid(Model.PagedList).AutoGenerateColumns()
.Columns(column =>
{
column.For(f => Html.ActionLink("Edit", "Edit", new { id = f.itemID}))
.Named("");
})
.Sort(Model.GridSortOptions);
)
但这只给了我一列“编辑”,因为我希望该列包含三个操作链接 - 编辑、设备、删除 - 以及所有三个特定行具有相同的 itemID。这是可以实现的吗?如果是这样,怎么办?如果没有,还有其他选择吗?
I'm trying to wrap my head around the proper syntax to achieve the following--or at least to find out if it's even do-able or if there is a better alternative solution.
Ok, out of the box, when you generate a strongly-typed View using the List scaffold under ASP.Net MVC3 you get a simple table with a column that has something like two or three Html.ActionLink() items representing common actions like so:
Edit | Details | Delete
I would like to use the MvcContrib grid and do the same, but I cannot figure out the correct syntax to get it to work. So far, in my Index.cshtml, I have the following snippet:
@(
Html.Grid(Model.PagedList).AutoGenerateColumns()
.Columns(column =>
{
column.For(f => Html.ActionLink("Edit", "Edit", new { id = f.itemID}))
.Named("");
})
.Sort(Model.GridSortOptions);
)
but that just gives me one column for "Edit", where as I want the column to contain three action links--Edit, Devices, Delete--with all three having the same itemID for the particular row. Is this achievable? And if so, how? If not, is there an alternative?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用自定义列:
You could use a custom column:
也许它对某人有帮助:
Maybe it helps somebody:
您应该传递一个内联助手:
You should pass an inline helper: