Spreadsheet-Style Editing in APEX
Interactive Grid’s editable mode transforms a report into a spreadsheet-like editing surface where users can modify multiple rows, add new rows, and delete rows before saving all changes in a single operation. Configuring editable columns correctly is critical for both usability and data integrity.
Enabling Editing
In the Interactive Grid attributes, set “Edit Enabled” to Yes. Then for each column that should be editable, set the column’s “Type” to the appropriate item type: Text Field, Number Field, Select List, Date Picker, Switch, and so on. Columns you want to be read-only should have their Type set to “Display Only.”
Column Type Configuration
Each editable column type has settings that control its behavior:
-- Select List column: define the LOV in the column attributes
-- LOV Query:
SELECT department_name AS display_value,
department_id AS return_value
FROM departments
ORDER BY department_name
-- Cascading LOV: filter based on another column
-- Parent Column: REGION_ID
SELECT city_name AS d, city_id AS r
FROM cities WHERE region_id = :REGION_ID
For date columns, configure the format mask to match your application’s standard date format. For number columns, set the format mask and optionally the minimum and maximum values for client-side validation.
Row-Level Operations
Configure which operations are allowed in the grid’s DML Processes section. You can enable Insert, Update, and Delete independently. For each operation, APEX generates the appropriate DML automatically based on the grid’s source query. If your source is a view or a complex query, you may need to define custom DML processes using the “Target Type” of PL/SQL Code:
-- Custom update process
BEGIN
UPDATE orders
SET status = :STATUS,
ship_date = :SHIP_DATE,
updated_by = :APP_USER,
updated_dt = SYSDATE
WHERE order_id = :ORDER_ID;
END;
Validation in Editable Grids
Apply validations to individual columns through the column’s Validation section. APEX validates each changed row before submitting DML. For cross-column validation (like “end date must be after start date”), create a page-level validation that iterates over the changed rows using the APEX$ROW_STATUS and APEX$ROW_NUM substitution variables.
Lost Update Detection
Enable “Lost Update Detection” in the grid attributes to prevent one user from overwriting another user’s changes. APEX compares a checksum of the row’s values at load time with the current database values at save time. If they differ, APEX reports a conflict and the user must refresh before saving. This is essential for multi-user applications.