在ExtJS中过滤

时间:2018-09-19 09:02:48

标签: extjs zend-framework filter propel

我正在使用以下代码过滤extjs中的商店:

var date = this.getValue();
Ext.data.StoreManager.lookup('krankmeldungstore').clearFilter(true);
Ext.data.StoreManager.lookup('krankmeldungstore').filterBy(
    function(rec) {
        var datum_von_grid = rec.data.datum_von_grid.split(".");
        var datum_von_year = parseInt(datum_von_grid[2]);
        if (datum_von_year === date) {
            return true;
        } else {
            return false;
        }
    }, this);
Ext.data.StoreManager.lookup('krankmeldungstore').load();

到目前为止,问题仍然存在,即该函数返回truefalse,该实体仍然留在我的商店中。

感谢您的帮助, 丹尼尔

1 个答案:

答案 0 :(得分:1)

Ext.getStore('xxx')。filterBy()在本地处理从代理检索的数据。因此,如果您触发 Ext.getStore('xxx')。load() Ext.getStore('xxx')。reload()),这将清除本地过滤的数据从服务器检索到的数据。

您还可以使用 Ext.getStore('xxx')。load({params:{'param1':'value1'}})从服务器端进行过滤。

>

现在请注意,如果您想再次使用相同的参数,则可以调用 Ext.getStore('xxx')。reload(),现在等于 Ext.getStore ('xxx')。load({params:{'param1':'value1'}})。但是,如果您使用 Ext.getStore('xxx')。load(),就好像您没有向服务器发送任何参数。

最后 ,您应该首先使用 Ext.getStore('xxx')。load({params:{'param1':'value1'}}) Ext.getStore('xxx')。load()从服务器获取数据,然后使用filterBy将本地过滤器应用于检索到的数据。

NB:我假设您使用的是Ajax或rest代理而不是本地代理