You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Oracle APEX 21.1交互网格新增行后无法刷新当前行的问题求助

Fixing "selection-refresh" Failure on Newly Saved Rows in Oracle APEX 21.1

I've run into similar behavior with APEX 21.1's Interactive Grid (IG) changes, so let's break down why this is happening and how to fix it.

The Problem Breakdown

Your observation is spot-on: APEX 21.1 altered how selection state is managed for newly inserted rows after saving. When you add and save a row, the IG's internal selection model doesn't immediately recognize the new record as a valid selectable entry—hence getSelectedRecords() returns 0, and the selection-refresh action has nothing to target. Older rows work because they're fully registered in the grid's state after a page refresh or full IG refresh.

Proven Solutions

1. Refresh the Specific Record Directly (Best Approach)

Skip the selection dependency entirely by telling the IG's model to refresh your target record directly. This avoids any selection state issues:

// Get the grid view and target record
const gridView = apex.region('MY_GRID').widget().interactiveGrid("getViews", "grid");
const targetRecord = gridView.model.getRecord(lineId); // lineId = your row's ID

// Refresh the record in the model
gridView.model.refreshRecords([targetRecord], { refreshColumns: true });

This method updates the record's data in the grid without relying on selection, and it's lightweight compared to full refreshes.

2. Fix Selection State Before Refreshing

If you still want to use selection-refresh, you need to ensure the grid is fully ready post-save before setting the selection. APEX 21.1 requires waiting for the IG's "ready" state to finish post-save processing:

const ig = apex.region('MY_GRID').widget().interactiveGrid();
const gridView = ig.getViews("grid");
const rec = gridView.model.getRecord(lineId);

// Wait for the grid to complete any pending operations
ig.waitFor('ready').then(() => {
    // Set selection explicitly
    gridView.setSelectedRecords([rec], { keepCurrent: false });
    
    // Verify selection (for debugging)
    const selCount = gridView.getSelectedRecords().length;
    console.log('Selected records after fix:', selCount);
    
    // Now trigger selection refresh
    ig.getActions().invoke("selection-refresh");
});

The waitFor('ready') call ensures the grid has finished syncing the new row to its internal state, making the record eligible for selection.

3. Explicit Record Refresh Action

If the above don't work, you can use the IG's built-in "refresh" action with a record-specific target:

apex.region('MY_GRID').widget().interactiveGrid("getActions").invoke("refresh", {
    refreshType: "RECORD",
    recordId: lineId
});

This is a more direct action that targets the row by ID, bypassing selection entirely.

Why This Happens in 21.1

Oracle updated the IG's data synchronization logic in 21.1 to optimize post-save performance. Unfortunately, this introduced a delay where newly saved rows aren't immediately added to the selection model. The grid needs a moment to sync the new row's metadata before it can be selected or refreshed via selection-based actions.

内容的提问来源于stack exchange,提问作者jashka34

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.30 20:57:32