【问题标题】:How to show link or action column in Kendo Grid如何在 Kendo Grid 中显示链接或操作列
【发布时间】:2015-05-03 08:59:06
【问题描述】:

我正在使用 Kendo Grid,单击列时需要链接。我想要字段:“姓名” link.and 为链接 Name

设置 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>"
   },

【问题讨论】:

    标签: kendo-ui kendo-grid


    【解决方案1】:

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

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

    您可以通过在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())
    

    试试看,我没测试过。

    【讨论】:

    • 感谢如何使用此示例设置模板 @Html.ActionLink("", "Index", "Home"),使用时请参阅错误 SyntaxError: expected expression, got '<#=姓名#>,
    • @saeed 我昨天更新了答案。你看见了吗?很抱歉没有让你知道。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-18
    • 1970-01-01
    相关资源
    最近更新 更多