Translate

Montag, 10. September 2018

APEX 5.1/18.2 - Update several rows in a tabular form / GRID

APEX 5.1 - 18.2

this is to answer a thread from the APEX community forum, therefore in English - sorry:

Question: How to update several rows in a tabular form:

I answered:

In 18.2 recommend to use the interactive grid... (tabular form is legacy...)





the grid has an inbuilt row-selector - even select-/deselect-all....

Create a region of type "interactive grid" and enable it to edit. - then...
steps:
1) create a button and name it "update STATUS rows"
2) create a dynamic action and name it "update_status_rows_DA" of type (WHEN...) Event: click - type: Button -
3) add a true action - action: Execute Javascript code
4) settings/code:

  1. var record;  
  2. //Identify the particular interactive grid  
  3. var ig$     = apex.region("my_region_name").widget();  
  4.   
  5. //Fetch the model for the interactive grid  
  6. var grid    = ig$.interactiveGrid("getViews","grid");  
  7.   
  8. //Fetch the model for the interactive grid  
  9. var model   = ig$.interactiveGrid("getViews","grid").model;  
  10.   
  11. //Fetch selected records  
  12. var selectedRecords = apex.region("my_region_name").widget().interactiveGrid("getViews","grid").view$.grid("getSelectedRecords");  
  13.   
  14. //Loop through selected records and update value of the STATUS column  
  15. for (idx=0; idx < selectedRecords.length; idx++)   
  16. {  
  17. //Get the record  
  18. record = model.getRecord(selectedRecords[idx][0]);  
  19.   
  20. // set Value von column STATUS on "VALID"     
  21. model.setValue(record,"STATUS"'VALID');  
  22. // optional...  
  23. model.setValue(record,"ROW_AMENDED_BY"'&APP_USER.');  
  24. model.setValue(record,"ROW_AMENDED_DATE"'&P14_DATE.');  
  25.        }  

execution options:
Event: Update_rows_DA
Fire when event result is: TRUEFire on initialisation: NO

Update 3.8.2019 (for Apex 18.2 and on...)
John Snyder-Oracle replied recently in a thread as follows:

"Look at the built in copy down functionality. Actions -> Selection -> Copy Down. Go into Cell Selection mode first. Then edit the column in the first row. Then select the column range over as many rows as you require and use copy down."

Keine Kommentare:

Kommentar veröffentlichen