mikestu12
mikestu12

Reputation: 1

Oracle Apex 4.2 Tabular Form checkbox for changed column value

I have an Apex Tabular form:

ID Name    Title   Class    ROW_EDIT <br>
1  Smith    Mgr     AP      (checkbox)<br>

etc...

I am trying to activate the 'checkbox' ROW_EDIT column - which has a default value of Y - when the user changes the value for the tabular form column Class (Select list) in the same row. I can change the ROW_EDIT attribute to text (ie, Y) if easier...

I have no apex_items for the page to reference - all columns are tabular form.

I have researched some dynamic change events - but I can't seem to get the row-reference to set correctly.

Any help would be greatly appreciated. Thanks

Upvotes: 0

Views: 764

Answers (1)

Dmitriy
Dmitriy

Reputation: 5565

Unfortunately, last time I saw APEX 4.2 was 2 years ago and I don't have it now.
The idea is in the following:

  • Add onchange event to select list. I don't remember is there an easy way to do this. If not, you can create a select list manually using APEX_ITEM package. To do this, write in the source query:

    select apex_item.select_list_from_lov (
             p_idx => 10, 
             p_value => class, -- it is a name of a table column
             p_lov => 'my_lov_name', 
             p_attributes => 'onchange="my_func.call(this);"')
      from ...
    
  • In page properites (JavaScript section), create a javascript function:

    function my_func () {
       this.parentElement.parentElement.getElementsByTagName("input")[0].checked = true;
    }
    

Parameter this in the function is a reference to select list. Hence, this.parentElement.parentElement - reference to row with the triggering select list, getElementsByTagName("input")[0] is a checkbox. If you have several input elements in the row, use proper index instead of 0.
How this JavaScript code works you can check here: https://codepen.io/anon/pen/NvPmPp

Upvotes: 0

Related Questions