Reputation: 2464
I have a grid with most cells bound to model members at the first level. However, my model also contains object members, and I am binding a few columns to members within the object. I am using incell editing, but I obviously want to restrict editing on certain fields.
Here is an small example of my model:
{
Id: 123456,
Name: 'some name',
Cost: 34.56,
Station: {
CallLetters: 'WKGB',
NetworkId: 123
}
}
I am able to bind to the grid without any issue using the following:
schema: {
model: {
fields: {
Id: { type: "number", editable: false },
Name: { type: "string" },
Cost: { type: "number" },
Station: { CallLetters: { type: "string", editable: false }, editable: false }
}
}
}
and:
columns = [
{ title: 'Id', field: 'Id', hidden: true, menu: false },
{ title: 'Station', field: 'Station.CallLetters', width: 80 },
{ title: 'Name', field: 'Name', width: 120 },
{ title: 'Cost', field: 'Cost', width: 95, format: '0:c2' }
]
As you can see, I am setting (and trying to set) certain fields to editable: false, and this works just fine for the Id field, and any other field at the top level of my model, but it does not work for the Station.CallLetters field. The Station column is still editable. Everything else is working fine.
Upvotes: 3
Views: 1102
Reputation: 2464
I originally got around this by simply creating a column detail template that held the same data item:
var stationContent = kendo.template('${Station.CallLetters} ');
and
{ title: 'Station', template: stationContent, width: 80 },
However, from Telerik:
This can be done by specifying the editable options in a separate model field, which explicitly refers to the nested property. For example:
"Station.CallLetters": { editable: false },
This is easily the most favorable method. Strange I didn't at least try to put the key in quotes.
Upvotes: 2