Hi Scott,
Since the update was happening successfully when I used a text box instead of a select box, I assumed the issue must be with how I had set up the
select box widget and you would be interested to see only the "front end" code associated to the select widget. Apologies.
Since the back end RPG was not updating the values as required, I came up with a front end "work around" to populate the select boxes with "1=SELECT".
The onload and onclick events are part of this work around.
The work around uses the script below to set the values. This script would fire on an onClick event of the "Select All" button.
Code: Select all
let recordCount = getObj("S01").grid.getRecordCount();
let isSelected = sessionStorage.getItem('selected');
console.log(isSelected);
getObj("S01").grid.setNumberOfRows(recordCount + 1);
if ((isSelected === 'off') || (isSelected === null))
{
for(let recordIndex=0;recordIndex<=recordCount;)
{
getObj("S01").grid.setDataValue(recordIndex, "OPTION","1=Select");
recordIndex++;
}
sessionStorage.setItem('selected','on');
}
else{
for(let recordIndex=0;recordIndex<=recordCount;)
{
getObj("S01").grid.setDataValue(recordIndex, "OPTION"," ");
recordIndex++;
}
sessionStorage.setItem('selected','off');
}
getObj("S01").grid.setNumberOfRows(13);
The OnLoad script which you saw is to clear the values the above script populates. This solution works as required by me.
To replicate the exact issue I was facing earlier, I have re-created the attached dump after removing the onload and onclick scripts I had added.
Now when the user clicks the select all button, its response is tied to indicator *in11. When *in11 is on, the selectAll subroutine is executed from where exfmt selectW is done which displays a confirmation screen. If the user confirms by pressing F5 (*inke), the records should be updated.
But it still doesn't work even after setting text transform to "None" as you suggested.
The RPG is now assigning a value of '1=Select'. This matches the value I have set in the choices property of the select box. I believe this should
rule out the possibility that the RPG is passing an invalid value.
As was observed earlier, if I use a text box instead of a select box, the value gets updated successfully.
I have confirmed in debug mode that the code that assigns the value to the select box and updates the subfile is indeed executed.
Now to answer your question "Also I don't understand why you are changing the number of rows to 13" - as I found out while trying to implement my
work around in the onclick event, the grid.setDataValue sets the values of only those records which are visible on the screen. When it is srolled down,
the select boxes are blank. In order to solve this, I display all the records in the grid using "getObj("S01").grid.setNumberOfRows(recordCount + 1);"
Then I reset it back to display 13 rows using getObj("S01").grid.setNumberOfRows(13) as the grid should initially display only 13 records to fit on the screen.
Hope I am clear and have not confused you further. Please do let me know if you need further details.