Greetings,
As I mentioned in a previous post, the batch mode grid doesn't store its data in an easily accessible JavaScript data structure, and rather, uses the DOM as a data store, and we want an easy API to read and write cell values.
The BatchEditingManager has getCellValue and changeCellValue methods, but I think they are unreliable in some situations.
changeCellValue doesn't write directly to the table cell. It opens the cell for editing, sets the value, then closes the cell. This behaviour is not acceptable when setting a value to a cell of the currently being edited row. When I call the function, the whole row is closed.
I have scenarios in which I want to change the value of a read only cell when the row is open. For example, I have a grid with two columns, code, and name, with the name cell containing a search box that sets the value of the code cell when the user chooses an item.
At last, I had to write my setCellValue function as follows:
Which is hacky because it depends on the internal undocumented structure of the grid.
I hope a better alternative will be provided in the future.
As I mentioned in a previous post, the batch mode grid doesn't store its data in an easily accessible JavaScript data structure, and rather, uses the DOM as a data store, and we want an easy API to read and write cell values.
The BatchEditingManager has getCellValue and changeCellValue methods, but I think they are unreliable in some situations.
changeCellValue doesn't write directly to the table cell. It opens the cell for editing, sets the value, then closes the cell. This behaviour is not acceptable when setting a value to a cell of the currently being edited row. When I call the function, the whole row is closed.
I have scenarios in which I want to change the value of a read only cell when the row is open. For example, I have a grid with two columns, code, and name, with the name cell containing a search box that sets the value of the code cell when the user chooses an item.
At last, I had to write my setCellValue function as follows:
Edge.UI.GridExtensions.setCellValue =
function
(columnUniquName, dataItem, value)
{
var
tableView = dataItem.get_owner(),
cell = tableView.getCellByColumnUniqueName(dataItem, columnUniquName);
if
(!cell)
return
false
;
var
valueDiv = cell.querySelector(
".rgBatchContainer"
),
valueTextElement = valueDiv? valueDiv.childNodes[0]:
null
;
if
(valueTextElement)
valueTextElement.textContent = value;
else
if
(valueDiv)
valueDiv.innerHTML = value;
else
cell.innerHTML = value;
return
true
;
}
Which is hacky because it depends on the internal undocumented structure of the grid.
I hope a better alternative will be provided in the future.