0

すでにフィルタリングされたストアをフィルタリングする方法があるかどうか疑問に思っていました。グリッドと 2 つのフィルター (F1 と F2) があるとします。とりあえずやっていることは、

if(!F1 & !F2)
{
grid.store.load().filterBy(function(record, id){
                /*** My function to sort the entire store ***/
            }, this);
}
else if(F1 & !F2){
grid.store.load().filterBy(function(record, id){
                    /*** My function to sort the entire store ***/
                }, this);
}
else if (!F1 & F2) {
grid.store.load().filterBy(function(record, id){
                    /*** My function to sort the entire store ***/
                }, this);
}
else if (F1 & F2){
grid.store.load().filterBy(function(record, id){
                    /*** My function to sort the entire store ***/
                }, this);
}

そのグリッドにフィルターをどんどん追加していて、「 」の数がelse if指数関数的に増加しています... さらに、15 万件以上のレコードをフィルター処理しているため、変更時にすべてのレコードの && フィルター処理をリセットすると、かなりのコストがかかる可能性があります。

私が欲しいのは

if (F1){
 /** filter on the most recent version of the grid **/
}
if (F2){
/** filter on the most recent version of the grid **/
}

私が明確であることを願っています、ありがとう。

4

1 に答える 1

1

を使用しstore.getFilters().add()ます。

フィドル

Ext.application({
    name: 'Fiddle',

    launch: function() {
        var store = new Ext.data.Store({
            fields: ['x'],
            data: (function() {
                var out = [],
                    i;

                for (i = 0; i < 100; ++i) {
                    out.push({
                        x: i
                    });
                }
                return out;
            })()
        });

        var grid = new Ext.grid.Panel({
            store: store,
            columns: [{
                dataIndex: 'x'
            }],
            renderTo: Ext.getBody()
        });

        setTimeout(function() {
            store.getFilters().add({
                filterFn: function(rec) {
                    return rec.get('x') < 50;
                }
            });
            setTimeout(function() {
                store.getFilters().add({
                    filterFn: function(rec) {
                        return rec.get('x') < 10;
                    }
                });
            }, 1000);
        }, 1000);
    }
});
于 2015-11-17T09:40:48.377 に答える