oracle-apexoracle-apex-18.2

How to add a new record into an interactive grid using IG methods then set column's value using $s() api?


I am using Oracle Apex 18.2.

I have an interactive grid and a custom button to add a new row to the IG using,

apex.region("myRegionStaticId").widget().interactiveGrid('getActions').invoke('row-add-row'); then set a column's value using, $s("myColumnStaticId","2");. When I try it, it adds the first row without setting any columns' values and starts setting the value from the second row on. Even using selection-add-row or insert-record, there is always something with the first row. Here is a sample,

[https://apex.oracle.com][1]
ws = ESLAM_WS
user = forhelp
pwd = forhelppwd
app = TEST
page = Add Row on top of an IG.

Solution

  • Change the following code:

    $s("INGREDIENT_ID","2");
    

    with the following one:

    setTimeout(function(){ $s("INGREDIENT_ID","2"); }, 100);
    

    It seems that the IG needs a little time to render the new row before you are able to change any value.