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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Create JSON from IR

Faezeh EbrahimiJun 12 2024 — edited Jun 12 2024

I have a interactive report which has some columns with APEX_ITEM.SELECT_LIST_FROM_QUERY and APEX_ITEM.text and others are simple columns.
here's the sample of my query for report :

   SELECT 
   A.id ID
   ,APEX_ITEM.SELECT_LIST_FROM_QUERY(P_IDX   => 1,
                                       P_VALUE =B.id, 
                                       P_QUERY => ' SELECT C.name,C.id from 
                                                    C 
                                                    where C.DETAIL_id='||B.id
                                           ) LOV_COLUMN
                                           
     ,APEX_ITEM.text(p_idx => 3 , P_VALUE => MAX(B.DESCRIPTION),p_maxlength =>150,p_attributes => 'style="width:350px";') DESCRIPTION
   
   from A 
   left join B  ON B.DETAIL_ID =A.DETAIL_ID 
   WHERE A.D = :P5_VALUE_ID

And now I want to get the JSON of IR and use it for merge process on a button .

Here's my code to create JSON :

   function create_json()
   {
       var TBL =document.getElementsByClassName("classname")
       var allDataArr=[]; 
   $(TBL[1]).find('tr').each(function(index, element) {
   
   var row_data={};
       
       $(element).find('td').each(function(index2, element2) {
         if(index2 == 0){
             row_data.LOV_COLUMN=$(element2).find(":selected").val()  
           }         
   ///and other columns...
      
       }); 
       
       allDataArr.push(row_data)
   
   });
   
       }

I use index of td to get the selected value or input value . but there's something that can make problems for created JSON . if the user changes the order of column , the indexes of IR's columns would change and that make the JSON corrupted.
Is there any ways to create the JSON without having problems like this and use something like data-id in IG instead of column index ?

Comments
Post Details
Added on Jun 12 2024
4 comments
435 views