首页 > 解决方案 > Determine the list of IR filter's functions/operators in Oracle APEX 19.1

问题描述

Is there a way to hide some Functions/Operators in the Row Filter of APEX 19.1's Interactive Report? Some end-users get confused with as many functions/operators that they do not used.

Thanks for any considerations.

enter image description here

标签: oracleoracle-apexoracle-apex-19.1

解决方案


虽然 APEX 不支持开箱即用,但它可以使用 JavaScript。每次显示过滤器对话框时,都会将内容从服务器带到客户端并注入 DOM。您只需要在用户看到之前修改内容。实现此目的的一种方法是使用 MutationObserver 接口:https ://developer.mozilla.org/en-US/docs/Web/API/MutationObserver

以下是您可以执行的一些步骤(在 APEX 19.2 中测试):

  1. 转到交互式报告并将静态 ID设置为my-irr
  2. 转到页面级属性并将以下代码添加到函数和全局变量声明字段:

    function removeIRFilterOperators() {
      var irRegId = 'my-irr';
      var filterOperatorsToRemove = ['!=', 'ABS'];
      var observer;
    
      function detectFilterDialog(mutationsList) {
        for (var mIdx = 0; mIdx < mutationsList.length; mIdx++) {
          if (mutationsList[mIdx].addedNodes.length && 
            mutationsList[mIdx].addedNodes[0].classList &&
            mutationsList[mIdx].addedNodes[0].classList.contains('a-IRR-dialog--filter')) {
              removeOperators();
          }
        }
      }
    
      function removeOperators() {
        var anchors = document.querySelectorAll('#' + irRegId + '_row_filter_operators a');
    
        for (var aIdx = 0; aIdx < anchors.length; aIdx++) {
          if (filterOperatorsToRemove.includes(anchors[aIdx].textContent)) {
            anchors[aIdx].parentElement.parentElement.removeChild(anchors[aIdx].parentElement);
          }
        }
      }
    
      observer = new MutationObserver(detectFilterDialog);
    
      observer.observe(
        document, 
        {
          attributes: false,
          childList: true, 
          subtree: true
        }
      );
    }
    
    removeIRFilterOperators();
    

MutationObverver 使用该detectFilterDialog函数来检测过滤器对话框何时添加到 DOM。发生这种情况时,该removeOperators函数会从操作员列表中删除指定的选项。您需要做的就是更新filterOperatorsToRemove数组以包含您要删除的运算符列表。


推荐阅读