我正在尝试使用编辑命令链接来编辑一行剑道 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/