Oracle APEX: Working with Row Selection in Interactive Grid


The Interactive Grid (IG) in Oracle APEX provides a feature to select rows when edit mode is enabled. However, it comes with challenges such as:
Retrieving all selected records
Maintaining selected records between pagination pages
Preselecting specific records
Getting Selected Records
Starting from APEX 24.1, a new JavaScript API called selectionStateItem
allows setting an APEX page item with the selected values whenever the selection changes. More details are available in the APEX documentation.
Implementation
Add the following code to: IG > Attributes > Advanced > Initialization JavaScript Function
function (options) {
options.defaultGridViewOptions = {
selectionStateItem: "P100_SELECTED_IDS"
}
return options;
}
Result:
Persisting Selection Between Pages
By default, when pagination is set to "Page", selected records are lost when navigating between pages.
To retain selection, use the APEX JS API persistSelection
, which ensures records remain selected across pagination pages.
Implementation
Add the following code to: IG > Attributes > Advanced > Initialization JavaScript Function
function (options) {
options.defaultGridViewOptions = {
rowsPerPage: 5,
persistSelection: true
}
return options;
}
Result:
Preselect Records
If you need to retain selected records after a page refresh or preselect specific rows when the page loads, you can achieve this using JavaScript.
Implementation Add the following code to: Execute when Page Loads or a Dynamic Action on Page Load
var val = $v("P100_SAVED_IDS");
if (val) {
var array = val.split(":").filter(id => id.trim() !== ""); // Remove empty values
if (array.length > 0) {
apex.region('IG_DEMO').widget().interactiveGrid('setSelectedRecords', array);
}
}
This approach ensures that selected records persist, improving user experience when working with Interactive Grid selections in Oracle APEX.
Conclusion
By leveraging the selectionStateItem, persistSelection, and setSelectedRecords APIs in APEX Interactive Grid, you can efficiently manage row selection, ensuring a smoother user experience.
Subscribe to my newsletter
Read articles from Petar Simic directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Petar Simic
Petar Simic
Hi, I'm Petar — a passionate Oracle APEX Consultant with years of hands-on experience building robust, scalable, and user-centric applications. From optimizing Service Desk and Document Management systems to launching APEX PWA apps on Google Play and the App Store, I bring deep expertise in Oracle APEX, PL/SQL, ORDS, and web technologies. As an Oracle ACE, I actively contribute to the Oracle community by blogging, mentoring, and speaking at international conferences like APEX World, APEX Alpe Adria, HrOUG, and MakeIT. I’m also a certified APEX Developer and Specialist with a strong focus on integrating AI services and mobile-first design into enterprise solutions. Tech Stack: Oracle APEX, ORDS, SQL, PL/SQL, HTML, CSS, JavaScript, jQuery Certifications: Oracle Cloud APEX Developer Professional, Oracle ACE Associate, Oracle Foundations Associate Currently: Delivering APEX projects and training sessions remotely.