PDA

View Full Version : How to preserve filter on gridview/store with direct proxy upon reload



viewsrc
20 Nov 2011, 1:49 PM
Hi everyone,

I've got a store that uses a model with a direct proxy; remoteFilter is set to false.

My GridView shows the locally filtered data correctly when I set a filter programmatically like this:
store.filter({property: "foo", value: bar});

But when I call "store.load()" the local filter setting is reset.

My workaround so far is:

...var filters = new Array();
filters = store.filters.items;
store.load({
scope: this,
callback: function() {
store.filter(filters);
}
});

...

It kinda works but seems very wrong to me...

What am I overlooking?


[BTW: extjs 4.0.7]

flanders
20 Nov 2011, 11:08 PM
You are right the store is not filtering again after load and whether it should depends on who you ask. I think...

Based on going through the source: To retrieve the same result you should be able to call sort() on the store, without moving the existing filters around. The load method doesn't remove your filters, so no need to pass them again.

You can take a closer look at the source of the methods load() and filter() for more details