Mandy Walsh
Mandy Walsh

Reputation: 31

Oracle APEX - How to access Popup LOV value from Interactive Grid using JavaScript (some JS help please!)

Oracle APEX Version: 21.1.0

I have a number of interactive grids on an APEX page (one for each day of the week) and I want to save the data from each into an APEX Collection. The IG_MON interactive grid contains 3 columns, their Static ID's are:

COL_MON_PROJECT

COL_MON_HOURS

COL_MON_DESCRIPTION

I have a Dynamic action (for each day) that runs some JavaScript that saves the IG data into the following page items:

P704_MON_PROJECT

P704_MON_HOURS

P704_MON_DESCRIPTION

(Then after the Javascript has run, I then call an Ajax Callback process to add_member to my APEX collection).

It is successfully working for the columns COL_MON_HOURS and COL_MON_DESCRIPTION as the Column Types are "Text Field".

For the COL_MON_PROJECT column, I have set this as a Popup LOV which shows "Project Name" for display, and an ID for the return value.

When I use my code below to save the COL_MON_PROJECT Popup LOV value, in the session state I can see P704_MON_PROJECT is shown as [object Object].

I have tried a few different options, but I am not proficient enough in JavaScript to get it quite right!

var col_project;

var col_hours;

var col_description;



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



col_project = model.getFieldKey("COL_MON_PROJECT");

col_hours = model.getFieldKey("COL_MON_HOURS");

col_description = model.getFieldKey("COL_MON_DESCRIPTION");



model.forEach(function (igrow) {



   apex.item("P704_MON_PROJECT").setValue(igrow[col_project]);

   apex.item("P704_MON_HOURS").setValue(igrow[col_hours]);

   apex.item("P704_MON_DESCRIPTION").setValue(igrow[col_description]);



   apex.server.process('POPULATE_COLLECTION_MON', {

      pageItems: '#P704_MON_DATE,#P704_MON_PROJECT,#P704_MON_HOURS,#P704_MON_DESCRIPTION'

   }, {

      dataType: 'text',

      success: function (data) {

         if (data != 'SUCCESS');

      }

   });

});

Upvotes: 1

Views: 3970

Answers (2)

Mandy Walsh
Mandy Walsh

Reputation: 31

I figured this out with some console.log messages and saw that the Popup LOV was resolving to:

apex.item("P704_MON_PROJECT").setValue(igrow[col_project]) =
{v: "229592305603457980799039089331487048885", d: "My Project Name"}

I just needed to change this to:

apex.item("P704_MON_PROJECT").setValue(igrow[col_project].v) =
229592305603457980799039089331487048885

Upvotes: 2

TineO
TineO

Reputation: 1033

A DA to get values from an IG in js is complicated, not sure how to make your code work. But for diagnosing js code, you should run it manually in the browser console and see what it does step by step, and there you can also explore what the [object Object] actually is.

But for a different approach, if on each column you make a separate DA, you can just address the value of the column with :COL_MON_PROJECT(or whatever else).

So the table for monday would have three DAs one for project, one for hours and one for description. Each probably having an action Set Value, setting the value of P704_MON_... with MON_...

Also, from what I understand of your code, you look to be using single row interactive grids, which fill page items. Why not just have one IG for all the days, and then in the processing of the IG you fill the collection(if the collection is still even needed). Or if you dont want one IG for all the days, why not just fill the page items for each day individually?

Upvotes: 1

Related Questions