oracleoracle-apexoracle-appsoracle-apex-20.2

Setting date value in an Interactive grid based on a page item


I am trying to set a interactive grid column value (which is a date) based on a page item (which is also a date). I have already tried defaulting and using dynamic action set value (jquery seletor) to set item value to the interactive grid column but it does not work how I want it to work.

I have a page item called "P_DEF_DATE" and I want to set a date column in the interactive grid to this value but I want when I change the value in the page item and I click add row on the interactive grid, it must always use whatever value I have in the page item. For example:

P_DEF_DATE = 12-JAN-2021

when I click on add row in the interactive grid, my date column must equal to P_DEF_DATE and i add a few rows based on that date but then i change the date of P_DEF_DATE to:

P_DEF_DATE = 28-JAN-2021

now I want when I click on add row in the interactive grid, I it must show this new date from the page item in the date column in the interactive grid, keeping in mind the page does not refresh and I have rows with the date 12-JAN-2021.

Thank you in advance!


Solution

  • I implemented same few days ago. Following is what I did.

    1. Create Dynamic Action on Row Initialization Event, set Region to your IG
    2. Set True Action to Execute JavaScript Code
    3. Use code
    var model = this.data.model,
        rec = this.data.record,
        meta = model.getRecordMetadata(this.data.recordId);
    
    if ( meta.inserted ) {
        model.setValue(rec,"COLUMN_NAME", $v("P_DEF_DATE"));
    }
    

    Replace JOB with your column name and P_DEF_DATE with you Item name More details Here

    Also, out of curiosity, why there is no number like P1, P2 in your item name ??