【问题标题】:How to change the cell template in each row of mvc kendo grid如何更改mvc剑道网格每一行的单元格模板
【发布时间】:2015-08-31 03:11:07
【问题描述】:

我正在使用 MVC 的 Kendo UI 开发应用程序,我希望能够更改单元格的模板,但我不知道如何使用 Kendo 网格来实现它。我需要根据值更改每行中的单元格模板,如果是“字符串”我需要显示文本框,如果是日期值则单元格模板成为日期选择器。请帮我找到解决方案。

【问题讨论】:

    标签: c# asp.net-mvc kendo-grid


    【解决方案1】:

    您可以使用EditorTemplates(Views\Shared\EditorTemplates\ 文件夹)来完成,这是您想要的类型的部分视图。默认情况下,当您为新项目使用Telerik.ASP NET MVC Application 模板时,会创建一些编辑器模板。 您也可以通过UIHint("ViewName") 属性指定所需的视图。

    【讨论】:

    • 谢谢安德烈。当我用字符串属性列绑定列时,我必须在同一个单元格中添加不同的模板。对于同一列“EmployeeTemplate”,我有 3 个不同的模板。 'EmployeeTemplate' 的值由 'EmployeeType' 列确定,我需要在单元格中显示 datepicker、int 或 string 模板。当我添加时,公共字符串 MetadataColumnValue {get;set;} columns.Bound(c => c.MetadataColumnValue).ClientTemplate("#= MetadataDateTime #").Width("20%");数据网格列 columns.Bound(c => c.MetadataColumnValue) 变为字符串。日期选择器未显示。
    • 是否需要在显示或编辑器模板中显示 DatePicker?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-25
    • 2023-03-05
    相关资源
    最近更新 更多