Bulk Updating Interactive Grid Records
March 23, 2017 at 9:36 am | Posted in Oracle Developement | 6 CommentsAfter my previous post on Updating Interactive Grid Cells, I wanted to try bulk updating IG records.
In this example I want to bulk update the salaries and commissions for the employees. I created a new button called Double Salaries. When the button is clicked, the salaries of the selected employees get doubled. The employees with no salary get a salary of 1000. Sales people will get their commission updated to 10% of their new salary.
Employees are selected by clicking the row selector checkbox of the interactive grid. The interactive grid’s static ID is emps.
The work is done by the JavaScript action of a dynamic action on the Double Salaries button:
var record, sal; //Identify the particular interactive grid var ig$ = apex.region("emps").widget(); //Fetch the model for the interactive grid var grid = ig$.interactiveGrid("getViews","grid"); //Fetch the model for the interactive grid var model = ig$.interactiveGrid("getViews","grid").model; //Fetch selected records var selectedRecords = apex.region("emps").widget().interactiveGrid("getViews","grid").view$.grid("getSelectedRecords"); //Loop through selected records and update value of the salary column for (idx=0; idx < selectedRecords.length; idx++) { //Get the record record = model.getRecord(selectedRecords[idx][0]); //Get the current salary and commision values sal = model.getValue(record,"SAL"); job = model.getValue(record,"JOB"); comm = model.getValue(record,"COMM"); //If there is no salary, set it to 1000, else double it if (sal === '') { sal = 1000; } else { sal = sal * 2; } //Update the record with doubled salary and new commission model.setValue(record,"SAL", sal); //Set commission to 10% of salary for sales people if (job = 'SALESMAN') { comm = sal *.1; model.setValue(record,"COMM", comm); } }
6 Comments »
RSS feed for comments on this post. TrackBack URI
Hi there you got the typo in above code @ //Fetch selected records
var selectedRecords = apex.region”emps”).
Comment by pranav— June 6, 2017 #
Thanks pranav! Fixed it.
Comment by Christoph Ruepprich— June 6, 2017 #
I had to replace (@line 15) this:
idx < selectedRecords.length
for this:
idx < selectedRecords.length
Everything else worked perfect. Thanks 😉
Comment by Pedro Magalhães— June 11, 2018 #
the first one was “< ;”
Comment by Pedro Magalhães— June 11, 2018 #
Thx for the info. Getting special characters to show on WP can sometimes be a challenge. 😉
Comment by Christoph Ruepprich— June 12, 2018 #
[…] Bulk Updating Interactive Grid Records 2017.03 […]
Pingback by Oracle APEX 系列文章10:Oracle APEX Evangelion(EVA 補完計劃) - 程序員的後花園— June 24, 2018 #