简体   繁体   中英

Kendo grid field value needs to be different than displayed text

I have a grid in kendo with the following columns:

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

The datasource has the schema:

schema: {
    model: {
        id: "GroupId",
        fields: {
            Name: {editable: true},
            Description: {editable: true},
            Users: {editable: false},
        }
    }
}

My problem: I do not want Users to be editable, so it has the editable: false property. But this doesn't seem to be binding to my Users.length field.

Which of the following is the correct/implementable approach to this? I'm new to kendo, so I've had no luck figuring this out on my own.

  1. Can I have the field name refer to Users, and the display value be Users.length?
  2. Can I bind the field in the schema to Users.length somehow?

Set the field to whatever (not Users.length ) you can actually not even defined field. Then show the content using a template. Something like:

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

When you do not define field attribute, it automatically becomes not editable BUT you still have access to the fields of your model.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM