kendo-ui - Kendo ui 网格客户端模板 "Id is not defined"

标签 kendo-ui kendo-grid

我正在尝试使用编辑命令链接来编辑一行剑道 web ui 网格。问题是我无法使用语法 "#= Id #",Id 被定义为模型中的 id字段之一强>.这是数据源中定义的模式

    var dataSource = new kendo.data.DataSource({
        type: "json",
        .....
        schema: {
            model: {
                id: "Id",
                fields: {
                    Id: { type: "number" },
                    RequesterName: { type: "string" },
                    ...
                }
            },
            data: "data",
            total: "total"
        },
        ...
        pageSize: 5
});

还有剑道格

$("#request-grid").kendoGrid({
    dataSource: dataSource,
    ...
    columns: [{
        field: "Id", title: "Id", width: 35
    }, {
        field: "RequesterName", title: "Req Name", width: 175
    }, { 
    ...
    }, {
        command: [{ name: "edit", template: "<a href='@Url.Action("_SoftwareRequestEdit", "SoftwareRequest")" + "/#= Id #" + "'>Edit</a>" }]
    }],
    ...
});

使用上面的代码,当网格加载时我得到以下 javascript 错误

ReferenceError: Id is not defined
#11 http://localhost:49713/Admin/SoftwareRequest/SoftwareRequestList:3
#10 http://localhost:49713/Scripts/Kendo/kendo.web.js:294:22 eval (eval at ()
#9 http://localhost:49713/Scripts/Kendo/kendo.web.js:26361:44 Widget.extend._createButton()
#8 http://localhost:49713/Scripts/Kendo/kendo.web.js:27571:38 Widget.extend._cellTmpl()
#7 http://localhost:49713/Scripts/Kendo/kendo.web.js:27523:41 Widget.extend._tmpl()
#6 http://localhost:49713/Scripts/Kendo/kendo.web.js:27624:37 Widget.extend._templates()
#5 http://localhost:49713/Scripts/Kendo/kendo.web.js:25055:18 new Widget.extend.init()
#4 http://localhost:49713/Scripts/Kendo/kendo.web.js:2785:25 HTMLDivElement.()
#3 http://localhost:49713/Scripts/jquery-2.1.0.js:381:23 Function.jQuery.extend.each()
#2 http://localhost:49713/Scripts/jquery-2.1.0.js:137:17 jQuery.fn.jQuery.each()
#1 http://localhost:49713/Scripts/Kendo/kendo.web.js:2784:26 $.fn.(anonymous function) [as kendoGrid]

如您所见,我已经在模型中定义了 Id,但我仍然收到 ReferenceError: Id is not defined。相同的任何线索。

最佳答案

模型中的变量只能用于模板列,不能用于命令列。

基本上你可以通过完全使用 template 来实现你的目标列,您不必使用命令列。

关于kendo-ui - Kendo ui 网格客户端模板 "Id is not defined",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22981460/

相关文章:

javascript - 如何从剑道网格中获取选中的行?

javascript - 无论如何(内置/自定义写入)在 Kendo UI Grid 中进行内联编辑之前显示确认对话框?

kendo-grid - 仅当省略号处于事件状态时才显示剑道工具提示

javascript - X 轴格式

jquery - Kendo UI Mobile - 在 JQuery 中删除时,CSS 属性会在 View 转换时重置

kendo-ui - 如何增加 kenoui 上传小部件的 dropzone

asp.net-mvc - Kendo 网格模板中的 For 循环

jquery - Kendo UI网格/内联编辑中 "productService"是什么意思

javascript - 在 Kendo Grid 中定义列类型?

javascript - 获取kendo调度程序中选定 View 的开始和结束日期以过滤数据库查询中的事件