Hi,
Attempting to find away to set (compute, derive) the value of a cell based on contents of one or cells using “onCellEdit”.
Scenario is derive Criticality of a risk based on the Likelihood and Consequence (both of which are combos in separate cells), viz:
Likelihood {Rare, Likely, Almost Certain}
Consequence {Minor, Moderate, Major}
When either of the above cells are changed the Criticality cell is derived by rule.
Keeping it really simple for now:
p1grid.attachEvent("onEditCell", function(stage,rId,cInd,nValue,oValue){
//your code here
if (stage == 2){{
}
});
Stage 1 will drop down the combo for selection then after selection the cell contains the selected item and Stage 2 will fire.
Stage 2 is where nValue becomes available and can be used for deriving criticality.
When the function exits (into dhtmlx.js) it only takes a couple of F10s (Step over next function) before the dataprocessor is fired:
p1gridDataProcessor = new dataProcessor("model/upd_propvaluphp?context=Issue", true);
and nValue is persisted in the repository and the row (c0,c1) becomes bold.
After 6 x F10 the cell (c1) reverts to its previous (oValue).
After another 18 x F10 row becomes unbold still with oValue.
Doing the real work:
[code] p1grid.attachEvent(“onEditCell”, function(stage,rId,cInd,nValue,oValue){
//your code here
if (stage == 2){{
… derive the value of criticality, then update the cell and persist …
p1grid.cells(critrow,1).setValue(criticality);
p1gridDataProcessor.setUpdated(critrow,true);
}
});[/code]
In this case the DP is fired and it persists Criticality immediately.
The “onEditCell” event is finally exited and steps into dhtmlx.js.
2 x F10 the selected value bolds AND the DP is fired again to persist the selected Likelihood value.
6 x F10 the selected Likelihood value reverts to oValue - remains bold.
Resuming execution both cells become unbold.
Is there something I am missing or misunderstanding about this event handler?
Regards
Raymond
dhtmlx Version 4.2
Chrome v55