Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Simulate Popup LOV with setRecordValue

Jared CMay 13 2025 — edited May 13 2025

Oracle APEX 24.1 | Oracle DB 19c

Hi, I am trying to simulate the behavior of a Popup LOV. My Popup LOV is rendering as a modal dialog. When I select the option from the list in the modal dialog, the display value automatically renders in the appropriate cell.

I click this:

Modal dialog appears:

I pick one of them, and the appropriate (display) value then populates in the cell:

However, I am also programmatically adding data to the Interactive Grid. I do so with setRecordValue. Below is the full function I am using, however:

/**
* @function copyValuesToIg
* @param {String} igStaticId the static ID of the interactive grid
* @param {Array} itemsToCopy 2d array; [[pFieldName, pValue, Boolean (optional, default false, set to true if using static value instead of page value)]] 
* @example igUtil.copyValuesToIg('IG_DETAIL', [['NAME', 'P1_NAME'], ['AMT', 'P1_AMT']]);
* @link https://docs.oracle.com/en/database/oracle/application-express/18.2/aexjs/model.html#setRecordValue
*/
igUtil.copyValuesToIg = function (igStaticId, itemsToCopy) {
   const grid = apex.region(igStaticId).call('getViews', 'grid');
   const model = grid.model;
   const recordId = model.insertNewRecord();
   for (let i = 0;  i < itemsToCopy.length; i++){
       // [i][2] is a boolean and should be marked to "true" if the value is static
       // Otherwise, left unspecified, you'll get falsy
       if (itemsToCopy[i][2]) {
           model.setRecordValue(recordId, itemsToCopy[i][0], String(itemsToCopy[i][1]));
       } else {
           model.setRecordValue(recordId, itemsToCopy[i][0], apex.item(itemsToCopy[i][1]).getValue());
       }
   }
}

This works, except that it will populate the return value into the cell, rather than the display value.

Until I double-click on it.

I want to simulate that double-click. Or whatever would happen when the display value comes over from the Popup LOV modal dialog.

I've been messing around with grid.setSelectedRecords and grid.gotoCell, but no luck. I've been reviewing the source code of the Popup LOV and trying to determine what that is doing… but there's a lot of it and it is difficult to decipher.

Any suggestions / tips would be greatly appreciated.

This post has been answered by Karel Ekema on May 13 2025
Jump to Answer
Comments
Post Details
Added on May 13 2025
3 comments
308 views