ExtJS:如何通过过滤隐藏存储中的特定数据?

Nur*_*gin 0 load extjs store filter

我想隐藏从服务器返回的网格上的记录。

我已经设置了一个filteron store 并且可以访问该特定数据,但是我将如何处理隐藏/忽略此记录?

fooStore: {
    ....
    filters: [
         function(item) {
         let me = this;
         let theRecord = item.data.status === MyApp.STATUS; //true

         if (theRecord) {
              console.log(theRecord); //True
              console.log("So filter is here!!")
              //How to hide/ignore/avoid to load this specific data record to load Grid??
            }
         }
    ]
},
Run Code Online (Sandbox Code Playgroud)

返回 JSON;

{
  "success": true,
  "msg": "OK",
  "count": 3,
  "data": [
    { 
      //Filter achives to this record and aim to hide this one; avoid to load this record.
      "id": 102913410,
      "status": "P"
    },
    {
      "id": 98713410,
      "status": "I"
    },
    { 
      "id": 563423410,
      "status": "A"
    }
  ]
}
Run Code Online (Sandbox Code Playgroud)

Enz*_* B. 6

我无法保存我的小提琴,因为我没有 sencha 论坛的帐户,所以我给你我的代码:

Ext.application({
    name : 'Fiddle',

    launch : function() {
        var model = Ext.create('Ext.data.Model', {
            extend: 'Ext.data.Model',
            fields: [
                {name: 'id',  type: 'int'},
                {name: 'status', type: 'string'},
            ]
        });

        var store = Ext.create('Ext.data.Store', {
             autoLoad: true,
             model: model,
             proxy: {
                type: 'ajax',
                url:  'data.json',
                reader: {
                    type: 'json',
                    rootProperty: 'data'
                }
            },
            filters: [function(item) {
                if (item.data.status === "P") {
                    return true;
                }
                else {
                    return false;
                }
            }],
            listeners: {
                load: {
                    fn: function() {
                        console.log(this.getRange());
                    }
                }
            }
        });
    }
});
Run Code Online (Sandbox Code Playgroud)

我也像这样创建 data.json :

{
    "success": true,
    "msg": "OK",
    "count": 3,
    "data": [{
        "id": 102913410,
        "status": "P"
    }, {
        "id": 98713410,
        "status": "I"
    }, {
        "id": 563423410,
        "status": "A"
    }]
}
Run Code Online (Sandbox Code Playgroud)

我认为它靠近您的代码,并且在加载商店后,过滤器可以正常工作:

在此处输入图片说明

这是sencha小提琴链接:https : //fiddle.sencha.com/#view/editor

如果这不起作用,我不明白他妈的在做什么......