Beyond One Row at a Time
Many business workflows involve selecting multiple rows and performing an action: approve all selected orders, reassign multiple tasks, update the status of a batch of invoices. Interactive Grid supports multi-row selection, and combining it with efficient server-side processing creates a smooth bulk operation experience.
Enabling Multi-Row Selection
In the IG Attributes, set the “Row Selector” to a checkbox column. This adds a checkbox to each row and a “select all” checkbox in the header. Users can select individual rows, use Shift+Click for a range, or check the header checkbox to select all visible rows.
Collecting Selected Row IDs
// JavaScript: Get all selected primary key values
function getSelectedIds(regionId, columnName) {
var grid = apex.region(regionId).widget()
.interactiveGrid("getViews","grid");
var model = grid.model;
var selected = grid.getSelectedRecords();
return selected.map(function(rec) {
return model.getValue(rec, columnName);
});
}
Sending to the Server
// Send selected IDs as a colon-separated string
var ids = getSelectedIds("orderGrid", "ORDER_ID");
if (ids.length === 0) {
apex.message.alert("No rows selected.");
return;
}
if (ids.length > 100) {
apex.message.confirm("Process " + ids.length + " rows?", function(ok) {
if (ok) { processIds(ids); }
});
} else {
processIds(ids);
}
function processIds(ids) {
apex.server.process("BULK_APPROVE", {
x01: ids.join(":"),
x02: ids.length.toString()
}, {
success: function(data) {
apex.message.showPageSuccess(data.count + " orders approved.");
apex.region("orderGrid").refresh();
},
error: function(jqXHR) {
apex.message.alert("Error: " + jqXHR.responseText);
}
});
}
Server-Side: Efficient Bulk Processing
-- AJAX Callback: BULK_APPROVE
DECLARE
l_ids APEX_T_VARCHAR2;
l_count NUMBER;
BEGIN
l_ids := APEX_STRING.SPLIT(APEX_APPLICATION.G_X01, ':');
FORALL i IN 1 .. l_ids.COUNT
UPDATE orders
SET status = 'APPROVED',
approved_by = :APP_USER,
approved_date = SYSDATE
WHERE order_id = TO_NUMBER(l_ids(i))
AND status = 'PENDING';
l_count := SQL%ROWCOUNT;
COMMIT;
APEX_JSON.OPEN_OBJECT;
APEX_JSON.WRITE('count', l_count);
APEX_JSON.WRITE('status', 'ok');
APEX_JSON.CLOSE_OBJECT;
END;
Progress Feedback for Large Batches
For operations affecting hundreds or thousands of rows, provide progress feedback. Send the IDs in chunks using multiple AJAX calls with a progress bar, or submit the entire batch as a background job using DBMS_SCHEDULER and poll for completion. Never block the UI for more than a few seconds without a progress indicator.