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

Sencha Grid同一属性添加多Not Filter无效问题求助

Fixing Multiple "Not Equal" Filters for the Same Property in a Data Store

Hey there! I totally get why this is frustrating—adding multiple <> filters for the same property should logically exclude all those values, but instead only the last one takes effect. Let's break down why this happens and how to fix it.

Why Your Original Code Isn't Working

Most data store frameworks (like Ext JS, which your syntax appears to use) treat multiple filters targeting the same property as overrides rather than cumulative rules. When you add three separate filters for invitationStatus, the store ends up replacing each previous filter with the next one, leaving only the last active.

Solution 1: Use a Custom Filter Function (Most Flexible)

Instead of multiple individual filters, create a single filter that checks if the record's value isn't in your excluded list using a custom function. This works for both local and remote filtering (if your backend supports custom logic, or you're filtering client-side):

store.addFilter({
    filterFn: function(record) {
        // List all statuses you want to exclude
        const excludedStatuses = ['IN_PROGRESS', 'SENT_BY_COMPANY', 'SENT_BY_SYSTEM'];
        // Return true only if the status is NOT in the excluded list
        return !excludedStatuses.includes(record.get('invitationStatus'));
    }
});

Solution 2: Use the "notin" Operator (Framework-Dependent)

If your store framework supports the notin operator (Ext JS does, for example), you can simplify this into a single filter that targets all excluded values at once:

store.addFilter({
    property: 'invitationStatus',
    operator: 'notin',
    value: ['IN_PROGRESS', 'SENT_BY_COMPANY', 'SENT_BY_SYSTEM']
});

Just note: If you're using remote filtering (where the server handles the filter logic), your backend needs to support the notin operator for this to work correctly.

Quick Tip

Double-check your store's remoteFilter setting:

  • If remoteFilter: true, make sure your backend can process the filter format you choose (either the custom function's logic or the notin operator).
  • If remoteFilter: false, both solutions above will work seamlessly on the client side.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.29 08:13:09