Oracle APEX - 提交时验证选择

Oracle APEX - validating IG selection on submit

我的页面上有一个交互式网格,允许选择行。当用户单击按钮时,该页面会分支到另一个页面。我需要创建一个验证以确保只有在选择了某些记录时页面才会分支。最好的方法是什么?

我没有自命不凡,我的方法是最好的方法,但它有效:

你需要给你的按钮一个静态 ID(我的是 LinkButton)。

然后您应该在事件 Selection change [Interactive Grid] 的网格上创建动态操作。做出 Execute JavaScript Code 那个代码位应该做的 True Action :

if(this.data.selectedRecords[0] != undefined) {
    //This is what happens when rows are selected
    document.getElementById("LinkButton").disabled = false;
}
else {
    //This is what happens when no rows are selected
    document.getElementById("LinkButton").disabled = true;
}

** 可能不是最好的解决方案,很可能是使用 APEX'S API 中的 Grid Widget 实现此目的的方法,但我无法 return 任何对象从我的网格使用它。如果在该页面的任何网格中选择了任何行(如果您有多个 reports/grids 即),而不是在特定的交互式网格中,我的答案将禁用该按钮。

我的回答深受此人启发:http://thejavaessentials.blogspot.com/2017/03/getting-selected-rows-in-oracle-apex.html and this post :

**我在 APEX 19.1 上测试过它,但由于上面的人在 APEX 5 上工作,我猜它也应该在上面工作。