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!

How to create a row in the interactive grid programmatically or get handle to newly created row

Ajay Saxena-OracleJul 7 2017 — edited Jul 7 2017

Hi,

I am trying to create rows in an interactive grid using the javascript API. The data for the rows is obtained from other components. The approach I am following now is to create the rows and then setting values to the columns of the newly created row. Below is the code fragment that I am trying to use to add rows. I am having trouble finding reference to the newly created row and had to use the private array _changes in the model object to get the last added row. Is there a better way to do update the newly created row or if possible create a row by passing these values beforehand

JS code

apex.region( "RESOURCE_TIME_REGION" ).widget().interactiveGrid( "getActions" ).invoke( "row-add-row" );

model = apex.region("RESOURCE_TIME_REGION").widget().interactiveGrid("getViews", "grid").model;

//rec = apex.region("RESOURCE_TIME_REGION").widget().interactiveGrid("getViews", "grid").getSelectedRecords()[0];

//array of all records

rec_ary = apex.region("RESOURCE_TIME_REGION").widget().interactiveGrid("getViews", "grid").model._changes;

rec = rec_ary[rec_ary.length - 1]["record"]

// does not work as getActiveRecordId points to the deleted record when we delete a row

//rec_id = apex.region("RESOURCE_TIME_REGION").widget().interactiveGrid("getViews", "grid").getActiveRecordId();

//rec = apex.region("RESOURCE_TIME_REGION").widget().interactiveGrid("getViews", "grid").model.getRecord(rec_id);

model.setValue(rec,"GPO_ID",$("#P50_GPO option:selected").val());

model.setValue(rec,"FINANCIAL_YEAR",$("#P50_FINANCIAL_YEAR option:selected").val());

model.setValue(rec,"RESOURCE_ID",$("#P50_USER option:selected").val());

model.setValue(rec,"QUARTER_1", $v("P50_QUARTER_1"));

model.setValue(rec,"QUARTER_2", $v("P50_QUARTER_2"));

model.setValue(rec,"QUARTER_3", $v("P50_QUARTER_3"));

model.setValue(rec,"QUARTER_4", $v("P50_QUARTER_4"));

This post has been answered by John Snyders-Oracle on Jul 7 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 4 2017
Added on Jul 7 2017
2 comments
2,504 views