我是使用 Telerik Grid 的新手,基本上我在这里想要完成的是以下场景,我有一个包含一些字段的表单,并通过 ajax 在我的控制器上调用另一个操作以将模型生成为部分视图有以下网格,我的问题是我需要根据一些业务逻辑创建一些操作,我知道我可以使用列模板来做到这一点,问题是因为我使用 ajax 绑定它“松散”我的模板,环顾四周在互联网上,我发现你可以使用 js 函数生成链接,我的问题是不是那种混乱吗?我在服务器和客户端上复制相同的业务逻辑,必须有更好的方法来完成这个吗?
Html.Telerik().Grid(Model)
.Name("Grid")
.DataBinding(binding => binding.Ajax().OperationMode(GridOperationMode.Client))
.Columns(column =>
{
column.Bound(c => c.Id).Title("Id").Width(30);
column.Bound(c => c.Status);
column.Bound(c => c.DateReg);
column.Template(
@<text>
<div class="ActionsProvGrid">
<a href="@Url.Action("SomeAction", "Controller", new {id = item.id})">
<img src="../../Content/icons/ViewMore.png" alt="ViewMore" />
</a>
@if (@item.Status.Equals("ACT"))
{
<a href="@Url.Action("SomeOtherAction", "Controller", new {idOportunidad = item.id})">
<img src="../../Content/icons/invoice.png" alt="invoice"/>
</a>
}
</div>
</text>
).ClientTemplate("<#= GenearteIcons(data) #>");
})
.Sortable()