Skip to main content

Command Palette

Search for a command to run...

Oracle APEX: Working with Row Selection in Interactive Grid

Updated
2 min read
Oracle APEX: Working with Row Selection in Interactive Grid
P
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, UKOUG, OUGN, 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.

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.

J
Joe Kerr1y ago

Thanks, this is very helpful. Is there a way to select which column value is returned, or is it always the primary key?

More from this blog

Petar Simic, Oracle Blog

15 posts

Oracle APEX Consultant