如何在 Kendo 网格中显示 link 或操作列

How to show link or action column in Kendo Grid

我正在使用 Kendo 网格,单击列时我想要 link。我想要字段:"Name" link.and 为 link 名称

设置 css

这是我的代码:

columns: [
   { field: "Id", title: " id", template: "<a href='http://www.codeproject.com/'>Id</a>" },
   { field: "Name", title: "Product Name" },
   {
     title: "Action",
     template: "<a href='http://www.codeproject.com/'>Edit</a>"
   },

为此,您必须为您的列设置一个 template

{ 
    field: "Name", 
    title: "Product Name",
    template: "<a href=''>#= Name #</a>"
},

以及您可以通过将 class 添加到 a 标签来应用的样式。

更新:

要使用@Html.ActionLink我建议使用这种模板:

<script id="link-template" type="text/x-kendo-template">
    # var link = "@Html.ActionLink("{0}", "Index", "Home")".replace("{0}", Name); #
    #= link #
</script>

然后使用如下:

template: kendo.template($("#link-template").html())

试一试,我没测试过。