Reputation: 1863
I have a store where I want to set a filter in the beforequery event.
The problem is when I do it like this
store.addFilter({property:'name', value: 'xxx'});
the actuall addFilter call will send a request, which is a problem because it will fire the beforequery event again.
So I add the supresevent parameter to the function call
store.addFilter({property:'name', value: 'xxx'}, true);
but, in this case the request doesn't have the filter param at all.
Am I missing something ?
All I want to is to add a filter in a beforequery event and the let it do a request
Upvotes: 0
Views: 198
Reputation: 36
There's a property on the store called autoFilter
. Set it to false. It's a private property, therefore it's not in the doc.
Upvotes: 2
Reputation: 597
I've been struggling with a problem in a similar context. I wanted to set a filter upon the store using the setFilter()
method. But using this method I had encountered that the store triggered the load event twice. One request included the filter parameters, the other one didn't.
Request1:
Request2:
This behavior resulted in wrong information in my component. After a while of tinkering I encountered that I can bypass the setFilter()
method by invoking the filter() method of the store directly.
Grid-Code:
...
initComponent: function () {
var me = this;
me.callParent(arguments);
me.getStore().filter([
{
property: someProperty,
value: someValue
}
]);
},
...
Applying the filter this way has solved the issue for me. I hope this will help you as well.
Upvotes: 2