【发布时间】:2014-05-07 16:23:01
【问题描述】:
当我单击带有 ASP .NET MVC 的 Kendo UI 网格的“编辑”按钮时,我想添加到另一个页面的重定向。
这是基本代码:
@(Html.Kendo().Grid<ViewModel>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(x => x.Id);
columns.Bound(x => x.Name);
columns.Bound(x => x.Field1);
columns.Command(commands =>
{
commands.Edit();
commands.Destroy();
})
})
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => model.Id(x => x.Id))
.Read(read => read.Action("Read", "Home"))
.Update(update => update.Action("Edit", "Home"))
.Destroy(destroy => destroy.Action("Destroy", "Home"))
)
)
我尝试使用 HTML 属性,但它不起作用:
commands.Edit().HtmlAttributes(new { @class = "edit" });
然后,我尝试添加自定义编辑(通过 commands.Custom(...) 但不幸的是它只是用于 .Server() 数据绑定。
我可以使用客户端模板来完成,但我真的很想使用 Kendo UI 建议的默认按钮:
columns.Template(@<text></text>)
.ClientTemplate(
"<a href='" + Url.Action("Edit", "Home") + "/#=Id#'>Edit</a>");
你还有什么想法吗?
提前致谢。
【问题讨论】:
标签: asp.net-mvc kendo-ui kendo-grid kendo-asp.net-mvc