PDA

View Full Version : [Final] FilterFeature example needs to conform to store parameter encoding



stevil
28 Apr 2011, 6:50 AM
or vice versa.

Run the grid filtering example, and filter on a grid column. You'll notice that you get a SET of parameters sent with the filter operation, like "filter[0][field]", "filter[0][data][value]", etc. If you filter on the store directly, you get a single parameter, named based on the filterParam config, that's formatted as "[{ property: "name", value: "value" } ....]"

So, if I have my own external logic that needs to filter the store, AND I want to use the column filters, I have to create another Proxy or override ServerProxy's to make it behave like the example, or I have to rewrite the example to behave like ServerProxy does.

stevil

Alexey.Solonets
10 May 2012, 3:42 AM
Can't understand if there a solution. This makes FilterFeature to work with store's native filter method.



Ext.override(Ext.ux.grid.FiltersFeature, {

reload: function () {
var me = this,
store = me.view.getStore(),
start;


if (me.local) {
store.clearFilter(true);
store.filterBy(me.getRecordFilter());
} else {
me.deferredUpdate.cancel();
var filters = this.getFilterData();


if (filters.length > 0) {
store.filters.clear();
store.filter(filters);
}
else {
store.clearFilter();
}
}
},


getFilterData: function () {
var filters = [], i, len;


this.filters.each(function (f) {
if (f.active) {
var d = [].concat(f.serialize());
for (i = 0, len = d.length; i < len; i++) {
filters.push({
property: f.dataIndex,
value: d[i].value
});
}
}
});
return filters;
},


bindStore: Ext.emptyFn
});