网格中的 kendoui ClientTemplate 在 asp.net mvc 4 中不起作用 [英] kendoui ClientTemplate in Grid not working in asp.net mvc 4

查看:22
本文介绍了网格中的 kendoui ClientTemplate 在 asp.net mvc 4 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找答案,但我认为我遗漏了一些简单的东西.我有一个剑道网格,我希望其中一列作为到另一个页面的链接,并将 id 作为路由参数.但是,列单元格中的值是绑定值,我的模板没有改变.对此的任何见解将不胜感激.

I have been looking all over for the answer and think I am missing something simple. I have a kendo grid where I want one of the columns to be a link to another page with the id as a route parameter. However, the value in the column cells are the bound values and are unchanged by my template. Any insights to this will be appreciated.

@(Html.Kendo().Grid((IEnumerable<ProviderAccess>)Model.Providers)
.Name("grants-grid")
.Columns(columns =>
{
    columns.Bound(a => a.ProviderName);
    columns.Bound(a => a.HasAccess);
    columns.Bound(a => a.ProviderId).ClientTemplate("#= toggleLink(data) #");
})
.Scrollable()
)

<script>
function toggleLink(access) {
    var action = '@Url.Action("Toggle", "Access")';

    var html = kendo.format("<a href='{0}/{1}'>Toggle...</a>",
        action,
        access.ProviderId
    );

    return html;
}
</script>

推荐答案

当 Kendo Grid 像您的代码一样绑定到服务器端的数据源时,ClientTemplate 未使用.

ClientTemplate isn't using when Kendo Grid is binded to a dataSource on server side like your code.

您应该使用如下列的模板方法

You should use Template method of columns like below

 columns.Template(p => "<a href='..../Toggle/Access/" + p.ProviderId + "'>Click</a>");

这篇关于网格中的 kendoui ClientTemplate 在 asp.net mvc 4 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆