在extjs中的store对象上应用多个过滤器

时间:2013-11-15 11:03:38

标签: extjs

我正在尝试在商店中实现多个过滤器。这是我的代码

var record = hg_mGrid.store.getAt(0);
        var switch_id_cust_group=record.get("switch_id_cust_group");
        hg_nmDs.filter([
                        {property: 'name', value: userFilterName},
                        {property: 'switch_id_cust_group', value: switch_id_cust_group}
                        ]);

hg_nmDs是一个商店对象,我想过滤其名称和switch_id_cust_group值的数据。我没有收到任何错误,但没有应用两个过滤器标准。

我也尝试过这种方式:

var filters=[
                       new Ext.util.Filter({
                        filterFn: function(hg_nmGrid){
                           return hg_nmGrid.get('name') == userFilterName && hg_nmGrid.get('switch_id_cust_group') == switch_id_cust_group;
                        }
                       })
                  ];
        hg_nmDs.filter(filters);

但是对于“var filters = [”这一行,面对错误“SCRIPT445:对象不支持此操作”。你能帮我完成这件事吗?

1 个答案:

答案 0 :(得分:1)

应用过滤器后,您必须加载商店。

var filters = new Ext.util.Filter({ 
    filterFn: function(hg_nmGrid){ 
        return hg_nmGrid.get('name') == userFilterName && hg_nmGrid.get('switch_id_cust_group') == switch_id_cust_group; 
    } 
}) ; 
store.filter(filters);
store.load(function(){
    console.log('Store should be filtered, when this callback function is called');
})