I have interactive grid based on this query :
select id_no,
TESTID,
UNITID ,
result,
MEAN,
SD,
ROUND(((result - mean) / sd),2) AS SDI ,
LOW_LIMIT,
HIGH_LIMIT,
PERF_ID,
VALIDATED
FROM HAJJ_QC_RESULTS
where sample_id = :P13_SAMPLE
AND hospital_no = :P13_HOSPITAL
AND approved_date = :P13_FROMDATE
Then I created button with dynamic action when click the button I need to calculate PERF_ID column this is the java script code and the button working when click the button its calculating the data in the grid this is the code executed with dynamic action
var widget = apex.region('validate').widget();
var grid = widget.interactiveGrid('getViews','grid');
var model = grid.model;
var v_amount = 0;
model.forEach(function (r) {
v_amount = 0;
model.setValue(r,'VALIDATED',2)
if (model.getValue( r , "SDI") >= 0 && model.getValue( r , "SDI") <= 1 )
{
v_amount += 1
model.setValue(r,'PERF_ID',v_amount)
//$s("PERF_ID",v_amount)
}
else if
(model.getValue( r , "SDI") <= 0 && model.getValue( r , "SDI") >= -1 )
{
v_amount += 1
model.setValue(r,'PERF_ID',v_amount)
//$s("PERF_ID",v_amount)
}
else if
(model.getValue( r , "SDI") >= 1.01 && model.getValue( r , "SDI") <= 1.5 )
{
v_amount += 2
model.setValue(r,'PERF_ID',v_amount)
//$s("PERF_ID",v_amount)
}
else if
(model.getValue( r , "SDI") <= -1.01 && model.getValue( r , "SDI") >= -1.5 )
{
v_amount += 2
model.setValue(r,'PERF_ID',v_amount)
//$s("PERF_ID",v_amount)
}
else if
(model.getValue( r , "SDI") >= 1.6 && model.getValue( r , "SDI") <= 2 )
{
v_amount += 3
model.setValue(r,'PERF_ID',v_amount)
//$s("PERF_ID",v_amount)
}
else if
(model.getValue( r , "SDI") <= -1.6 && model.getValue( r , "SDI") >= -2 )
{
v_amount += 3
model.setValue(r,'PERF_ID',v_amount)
//$s("PERF_ID",v_amount)
}
else if
(model.getValue( r , "SDI") > 2 )
{
v_amount += 4
model.setValue(r,'PERF_ID',v_amount)
//$s("PERF_ID",v_amount)
}
else if
(model.getValue( r , "SDI") < -2 )
{
v_amount += 4
model.setValue(r,'PERF_ID',v_amount)
//$s("PERF_ID",v_amount)
}
v_amount = 0;
})
the issue when I click save button its not saving PERF_ID column data I checked the DML process I have only one editable region what is the reason why not saving the data ?
Note : if I type the data in column PERF_ID one by oy one for every row and save its saving but when the data fill by java script code its not saving it ?
Use:
model.setValue(r,'PERF_ID',v_amount.toString())
From https://docs.oracle.com/en/database/oracle/apex/23.2/aexjs/model.html :
‘The model has very few restrictions on the values of fields. However typically when the model data is backing APEX items or HTML form controls the values will all be strings.’
Server side, APEX will convert to a number, taking into account any format mask.