【问题标题】:How to use a Kendo grid with a column template如何将 Kendo 网格与列模板一起使用
【发布时间】:2012-12-10 11:59:40
【问题描述】:

我正在尝试根据example here 将操作链接放入网格单元格中:

columns.Template(@<text>
    @Html.ActionLink("Edit", "Home", new { id = p.ProductID })
</text>);

但没有成功。
由于示例中的错误,它无法编译。我尝试替换为:

columns.Template(p => @<text>
    @Html.ActionLink("LinkTitle", "Edit", "Home", new { id = p.ProductID })
</text>);

得到:

CS0201:仅赋值、调用、递增、递减、等待和新建 对象表达式可以作为语句使用

然后我尝试了:

columns.Template(p => {
    Html.ActionLink("LinkTitle", "Edit", "Home", new
    {
        id = p.ProductID
    });
});

得到:

System.NotSupportedException

那么我在哪里可以找到一个稳定和使用Kendo UI网格的列模板的完整示例?

【问题讨论】:

  • 你试过了吗? columns.Template(@&lt;text&gt; @Html.ActionLink("Edit", "Home", new { id = @item.ProductID }) &lt;/text&gt;);

标签: kendo-ui kendo-grid


【解决方案1】:

您需要在 razor 模板委托中使用 item。它是隐式变量名。将您的代码更改为:

columns.Template(@<text>
    @Html.ActionLink("Edit", "Home", new { id = item.ProductID })
</text>);

您链接到的帮助主题有误,我们会尽快修复。

【讨论】:

  • 我应该把我的评论作为答案;)。
猜你喜欢
  • 2014-01-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-07-26
相关资源
最近更新 更多