I have a telerik :RadGrid in my project with a Master, Detail configuration. Both Master and Detail tables are have EditMode='Batch'
I need to dynamically set some columns to readonly on a per row basis. I used BatchEditOpening() to acheive this by setting args._cancel to true on the columns that need to be read only. There is more logic to determine the editability than in the example but the end result is the same: setting args._cancel = true if the field needs to be not editable. To replicate the issue:
click the built in 'Add new record' button 3 times. 3 rows are created as expected.
Then click any where in any of those rows, which should open the row for edit which it does. An error in the telerik function _openCellinEditMode()
It calls this function for the cells that were set to args._cancel = true in the BatchEditOpeining function. The _openCellinEditMode function fails when the following line is executed if (o && $telerik.getElementByClassName(o.cell, e).style.display === "") because there is no element with the rgBatchContainer class that it is looking for because this cell is no longer editable.
Is anyone aware of this issue? and is there a workaround / fix for it?
If I take the code out of the BatchEditOpening function, the error does not occur. It also doesnt occur as each row is added. I have stepped through the code and for each new row added it only calls _openCellinEditMode() for the appropriate editable columns. Then when you click on a cell to edit it will fail by calling the function for a column that has edit cancelled.
function
BatchEditOpening(sender, args) {
var
row = args.get_row();
//var cell = args.get_cell();
tableView = args.get_tableView();
//var column = args.get_column();
var
columnUniqueName = args.get_columnUniqueName();
args._cancel =
false
;
var
rowstatus =
''
;
if
(
columnUniqueName ==
"NotEditableColumn"
) {
args._cancel =
true
;
}
}
_openCellInEditMode:
function
(q) {
var
u =
this
;
var
n = q.cell;
var
s = u._getEditorControlsContainer(q.tableView, q.column.get_uniqueName(), n);
var
r = u._getDataControl(s);
var
t = s.parentNode;
var
p = u._getSetCellValue(n);
var
o;
if
(t.tagName.toLowerCase() ===
"td"
|| (u._currentlyEditedRow && n.parentNode.id !== u._currentlyEditedRow.id)) {
if
(u._currentlyEditedRow && n.parentNode.id !== u._currentlyEditedRow.id) {
t = u._currentlyEditedRow.cells[n.cellIndex];
}
o = u._getCellDataToOpenEdit(t);
if
(o && $telerik.getElementByClassName(o.cell, e).style.display ===
""
) {
if
(!u._updateCellValue(o)) {
return
false
;
}
u._currentlyEditedCellInfo =
null
;
}
}