Reputation: 1613
How i can enable certain fields on add mode and disable on edit mode. I have add the following code but i unable to enable the description field on add mode. Please advise how I can achieve this?. Thank you
model.fields(p=> p.Description).Editable(false);
I want to enable description on add mode and disable on edit mode. THe following code is not working. Please advise if anything wrong with the code and if any other way to do it. THank you
function onEdit(e) {
var indexCell = e.container.context.cellIndex;
var grid = $('#BTSession').data('kendoGrid');
if (!e.model.isNew()) { // when Editing
if (indexCell != 'undefined' && grid.columns[indexCell].Title == "Description") {
$('#BTSession').data("kendoGrid").closeCell();
}
}
}
Upvotes: 2
Views: 8795
Reputation: 40917
There are two problems:
title
is lowercase. The check should be: grid.columns[indexCell].title
isNew()
is always false
. Alternatively you might check for id
being undefined
when you add a new record.Something like:
function onEdit(e) {
var indexCell = e.container.context.cellIndex;
var grid = $('#BTSession').data('kendoGrid');
if (e.model.id) { // when Editing the id is defined
if (indexCell != 'undefined' && grid.columns[indexCell].title == "Description") {
grid.closeCell();
}
}
}
NOTE: If in your model the id
column is not called id
(lets say myId
) use the correct name.
EDIT: See a running example here
Upvotes: 2