Select/De-select all rows in IG in Oracle Apex

In this article we going to see how to select and de-select all rows in IG in Dynamic action. This work is done by execute a JavaScript code in dynamic action of button click.In the end of the article I have included the demo application for your reference.

Let see step by step approach how to do it.
Step 1: Create an IG (Interactive Grid) region and paste required SQL code. For demonstration purpose I used emp table (select * from emp).

Step 2: Assign static id for that IG region. E.g emp



Step 3: make sure that IG is editable.



Step 4: Create button (name- select_all) and create a dynamic action (on click event) for that button. Create true action and you can see many action types but we going to use JavaScript. So change it’s action type as “Execute JavaScript code”.

Step 5: paste the following code for select all row in a IG.
apex.region("emp").widget().interactiveGrid("getViews", "grid").view$.grid("selectAll");
apex.message.showPageSuccess( "All Rows selected successfully." );
Step 6: Similarly for de-select all rows in a IG, create another button and create dynamic action of JavaScript action type. Paste following code.

var ig$     = apex.region("emp").widget();
var selectedRecords = apex.region("emp").widget().interactiveGrid("getViews","grid").view$.grid("getSelectedRecords");
for (idx=0; idx < selectedRecords.length; idx++) {
    ig$.interactiveGrid("getViews", ig$.interactiveGrid("getCurrentViewId")).setSelection($());
}
if (selectedRecords.length==0){
    apex.message.clearErrors();
    apex.message.showErrors( { type:       "error",
                               location:  [ "page"],
                               message:   "Please select atleast one row to de-select.",  
                               unsafe:     false
                             }
                           );
}
else    {
    apex.message.showPageSuccess( "All Rows de-selected successfully." );
}




I hope this article will help you to select and de-select the row in IG. In case if you need any clarification or suggestion, kindly leave a message in the comments box.

Tag: Oracle apex 5, Oracle Apex IG, Process Rows in IG, Select all rows in IG , De-select all the row in IG.

Refresh IG (Interactive Grid) Column Header in Oracle APEX

In this article, we are going to see how to refresh IG (Interactive grid) header using JavaScript without page submission in Oracle APEX. In that end of the page, I have given demo application for your reference.

Now the following step will get you there to achieve your objective.

Step1:
  • create an Interactive grid in Apex and set "Static ID" for that region. for example, I have given my IG region id is 'emp'. Similarly set a "Static ID" for a column in which you want to refresh a header column. For example, I have given a static id to ename column 'ENAME'.



Step 2:

  • Create a button and set dynamic action "onclick event" for that button to achieve our objective. In that dynamic action event, create 'Execute JavaScript Code' action and paste the following code:

  •  In the above-given JavaScript Code, emp and ENAME are the Static ID for corresponding region and column.
  • After placing the JS code set 'Affected Element' to that particular region in that JavaScript Property.
That's it. Now you can run the application to which will refresh the header name correctly when you click the button. 


If you have any clarification or doubt or anything else, just leave a message in the comments box.