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

Oracle APEX 23.1交互式网格精准过滤仅含grey的条目

Oracle APEX 23.1交互式网格精确匹配单个标签过滤方案

可以直接通过自定义JavaScript逻辑修改交互式网格的过滤行为,无需修改SQL或添加外部过滤框,步骤如下:

  • 给目标交互式网格设置静态ID(比如ig_hats,可在交互式网格属性的「高级」标签页设置)
  • 在页面添加一个页面加载触发的动态行为,执行以下JavaScript代码:
// 获取交互式网格实例
const igInstance = apex.region("ig_hats").widget().interactiveGrid("getViews", "grid");

// 重写过滤处理器,针对category列做精确标签匹配
igInstance.model.filterProcessor = function(options) {
    // 先处理其他列的原生过滤逻辑
    const originalResult = this._super(options);

    // 仅对category列的contains操作、值为grey的情况做特殊处理
    if (options.column 
        && options.column.property === "CATEGORY" 
        && options.operator === "contains" 
        && options.value.trim() === "grey") {
        
        // 拆分category字段为标签数组,检查是否包含精确的grey
        const filtered = this.records.filter(record => {
            const tags = record.CATEGORY.split(",").map(tag => tag.trim());
            return tags.includes("grey");
        });
        
        // 更新过滤后的记录集
        this.filteredRecords = new apex.model.RecordSet(filtered, this);
        return this.filteredRecords;
    }

    return originalResult;
};

说明:

  • 代码中ig_hats需替换为你实际的交互式网格静态ID
  • CATEGORY要与交互式网格模型中对应的列名保持一致(通常为数据库列名的大写形式)
  • 该逻辑仅针对category列使用contains操作符且输入值为grey时生效,其他过滤场景仍保留原生行为

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.08 21:23:18