【问题标题】:Kendo grid field value needs to be different than displayed text剑道网格字段值需要与显示的文本不同
【发布时间】:2014-12-08 11:41:01
【问题描述】:

我在剑道中有一个包含以下列的网格:

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},
        }
    }
}

我的问题:我不希望用户是可编辑的,所以它有 editable: false 属性。但这似乎并没有绑定到我的 Users.length 字段。

以下哪项是正确/可实施的方法?我是剑道新手,所以我没有运气自己解决这个问题。

  1. 能否让字段名引用Users,显示值为Users.length?
  2. 我能否以某种方式将架构中的字段绑定到 Users.length?

【问题讨论】:

  • 您希望显示文本是用户名的长度并为名称取值?所以如果名称为 John 则显示 4 而 John 是值?!

标签: javascript kendo-ui kendo-grid


【解决方案1】:

将该字段设置为您实际上甚至无法定义的任何字段(不是Users.length)。然后使用模板显示内容。比如:

columns: [
    { field: "GroupId", hidden: true},
    { field: "Name", title: "Group Name"}, 
    { field: "Description", title: "Description"},
    { title: "Assigned Users", template: "#= Users.length #" }
]

当您未定义 field 属性时,它会自动变为不可编辑但您仍然可以访问模型的字段。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-10
    相关资源
    最近更新 更多