3
votes

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?
1
You want the display text to be the length of the username and value a name??So if name is John display 4 and John is the value?!CSharper

1 Answers

2
votes

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.