Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Form Values From Interactive Report Row

Tags:

oracle-apex

I have two tables: T1 and T2

Table T1 contains five columns: CT11, CT12, CT13, CT14, CT15

Table T2 contains 4 columns: CT21, CT22, CT23, CT24

I have a page with two regions. Region 1 is a Form on a Table using table T1. Region 2 is an Interactive Report ( IR ) on table T2.

The SQL for region 2 is:

select apex_item.RADIOGROUP(p_idx => 1, p_value => CT21) "Choose", CT22, CT23, CT24 from T2;

When the user click a radio button for a row in the Interactive Report, I would like the values in cells CT22, CT23, CT24 to populate the CT13, CT14, CT15 fields in the table form in region 1. If a user clicks another row radio button, the values should update.

Using Google and Stackoverflow, I have tried a bunch of options, but I just can't seem to find the correct method.

like image 865
RMAN Express Avatar asked Nov 01 '22 10:11

RMAN Express


1 Answers

Hopefully you understand how the f## arrays work a bit and what they look like in the generated html. To solve this you need javascript, and to understand that you do need to know what that html looks like. Nothing is as error-prone as misunderstanding this! Changing the f## array or any of the required columns name may stop the code from working properly, and while I don't think it is too hard, it is simply important to understand it. If you implement it, you will need to be able to support it and not rely on the help of a stranger on the internets. Having said that.

Create a dynamic action.

  • Event: After refresh
  • Selection type: Region
  • Region: your IR region
  • Condition: -
  • True action:

    • Execute javascript code
    • fire on page load: checked
    • Code:

      $("input[name=f01]", this.triggeringElement).change(function(){
      //mind the capitalization in the headers attribute selector
      var lRow = $(this).closest("tr"),
          lct22 = lRow.find("td[headers=CT22]").text(),
          lct23 = lRow.find("td[headers=CT23]").text(),
          lct24 = lRow.find("td[headers=CT24]").text();
      console.log("22: " + lct22 + " - 23: " + lct23 + " - 24: " + lct24);
      $s("P3_CT13", lct22);
      $s("P3_CT14", lct23);
      $s("P3_CT15", lct24);
      })
      

"input[name=f01]" will select the radiobuttons. You gave the radiobuttons p_idx=>1 and this will translate to the usage of array f01.

I made a small demo app too: http://apex.oracle.com/pls/apex/f?p=11964 . Log in with apex_demo/demo

like image 118
Tom Avatar answered Nov 18 '22 20:11

Tom