我在剑道中有一个包含以下列的网格:
columns: [
{ field: "GroupId", hidden: true},
{ field: "Name", title: "Group Name"},
{ field: "Description", title: "Description"},
{ field: "Users.length", title: "Assigned Users" }]
数据源具有模式:
schema: {
model: {
id: "GroupId",
fields: {
Name: {editable: true},
Description: {editable: true},
Users: {editable: false},
}
}
}
我的问题:我不希望 Users 是可编辑的,因此它具有 editable: false 属性。但这似乎并没有绑定(bind)到我的 Users.length 字段。
以下哪项是正确/可实现的方法?我是剑道的新手,所以我没有运气自己解决这个问题。
- 能否让字段名引用Users,显示值为Users.length?
- 我能否以某种方式将架构中的字段绑定(bind)到 Users.length?
最佳答案
将字段设置为您实际上什至不能定义字段的任何值(不是 Users.length
)。然后使用模板显示内容。像这样的东西:
columns: [
{ field: "GroupId", hidden: true},
{ field: "Name", title: "Group Name"},
{ field: "Description", title: "Description"},
{ title: "Assigned Users", template: "#= Users.length #" }
]
当您没有定义 field
属性时,它会自动变为不可编辑,但您仍然可以访问模型的字段。
关于javascript - Kendo 网格字段值需要与显示的文本不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26347932/