Bulk Updating Interactive Grid Records

March 23, 2017 at 9:36 am | Posted in Oracle Developement | 6 Comments

After 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);
    }

}

emps_bulk

6 Comments »

RSS feed for comments on this post. TrackBack URI

  1. Hi there you got the typo in above code @ //Fetch selected records
    var selectedRecords = apex.region”emps”).

  2. I had to replace (@line 15) this:
    idx < selectedRecords.length
    for this:
    idx < selectedRecords.length

    Everything else worked perfect. Thanks 😉

    • the first one was “&lt ;”

      • Thx for the info. Getting special characters to show on WP can sometimes be a challenge. 😉

  3. […] Bulk Updating Interactive Grid Records 2017.03 […]


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


Entries and comments feeds.

%d bloggers like this: