I have a unique requirement where I need to utilize two Interactive Grids to showcase my data. However, I am facing challenges in displaying the data and performing DML operations on the selected grid using Ajax from the backend. Despite attempting SQL and PLSQL approaches, I have not been able to achieve the desired output.
function makeCellsReadOnly() {
var grid = apex.region("readonly_emp_ig_id").widget().interactiveGrid("getViews","grid");
var model = grid.model;
var recordValue;
model.forEach(function(record, index, id) {
// getFieldKey method retrieves the index used for a given field name when accessing that field of a record. This allows access to a specific record field.
recordValue = record[model.getFieldKey("VALIDATED")];
var metadata = model.getRecordMetadata(id);
var fieldsObj = metadata.fields;
if (!fieldsObj) {
fieldsObj = metadata.fields = {};
}
if (!fieldsObj["EMPNO"] || !fieldsObj["JOB"] || !fieldsObj["MGR"] || !fieldsObj["ENAME"] ) {
fieldsObj["EMPNO"] = {};
fieldsObj["JOB"] = {};
fieldsObj["MGR"] = {};
fieldsObj["ENAME"] = {};
}
// using Object.keys(recordValue)[0] to fetch value
if (recordValue[Object.keys(recordValue)[0]] === 'Y') {
// set fields to read-only
fieldsObj["EMPNO"].ck = 1;
fieldsObj["JOB"].ck = 1;
fieldsObj["MGR"].ck = 1;
fieldsObj["ENAME"].ck = 1;
// trigger the change
model.metadataChanged(id);
} else {
fieldsObj["EMPNO"].ck = "";
fieldsObj["JOB"].ck = "";
fieldsObj["MGR"].ck = "";
fieldsObj["ENAME"].ck = "";
model.metadataChanged(id);
}
});
}