PDA

View Full Version : Remote store filter with comparison parameter



Michael Bogucki
27 Nov 2012, 2:28 AM
I try to filter my store remotly with comparision. Ext.util.Filter seems to have no comparison parameter (or at least i didn't found any). Something like the following code failed. The additional parameter isn't sent to the server.
my_store.filter([{property: "date_to", value: myDate, comparison: "ls"}]);

Is there any way to add custom parameters to your filter which can be submited to the server? Or is there an other way to solve this issue?

mitchellsimoens
29 Nov 2012, 12:10 PM
I usually add the filter stuff to extraParams and handle that on the server instead of using the store filter.

mostafaHTC
24 Aug 2015, 3:23 AM
hi
how to remove extra param when filter is clear?

bluehipy
24 Aug 2015, 4:10 AM
store.on('filterschange',
function(store, filters) {
if(!filters || !filters.length) {
store.proxy.extraParams = {};
}
});


or something :)

mostafaHTC
25 Aug 2015, 7:58 PM
This will erase all the extraparams, but I need to clean the filter params.:-?

bluehipy
25 Aug 2015, 11:39 PM
:) don't be lasy :))that filter management is fairly easy ;)

mostafaHTC
26 Aug 2015, 1:57 AM
I use bellow code for setting extraparam when filter is change

onFilterUpdateRender: function(grid,filters) {
var jsonFilters = grid.getFilterData();
if(!filters || !filters.length) {
this.store.proxy.extraParams = {};
}
Ext.each(jsonFilters, function(f) {
var param = f.field;
this.store.proxy.extraParams[param]=f.data.value;
}, this);
},

i set extra param of this store from controller with bellow code

this.store.proxy.extraParams.id=1;
and finally the bellow code will erase all the extra params although I need to clean the filter params
how i can remove anly filter extra params?

bluehipy
26 Aug 2015, 2:20 AM
on settting the filters keep track of names:
onFilterUpdateRender: function(grid,filters) { var jsonFilters = grid.getFilterData(); if(!filters || !filters.length) { this.store.proxy.extraParams = {}; }this.store.myExtraFilters = this.store.myExtraFilters || []; Ext.each(jsonFilters, function(f) { var param = f.field; this.store.proxy.extraParams[param]=f.data.value; this.store.myExtraFilters.push(param); }, this); },on cleaning the filters, you just delete what is stored in this.store.myExtraFilters
Ext.Array.each(this.store.myExtraFilters, function(f){ delete me.store.proxy.extraParams[f];});this.store.myExtraFilters = [];:)