-
4 Sep 2012 1:41 AM #1
Answered: parameter field or property in remote filter with grid and store
Answered: parameter field or property in remote filter with grid and store
Hi,
to avoid managing two param's name in remote script,
is it possible to give the same param field name to both filters with ExtJS ?
store filter (Ext.util.Filter)
param property is used to identify field name
grid filter (Ext.ux.grid.FiltersFeature)Code:{property: "fieldname",value:"myvalue"}
param field is used to identify field name
Code:{field:"fieldname", value:"astring", type:"string"}
-
Best Answer Posted by vietits
Try this:
Code:var store = Ext.create('Ext.data.Store', { ... remoteFilter: true, filters: [{ property: 'field1', value: 'value1' },{ property: 'field2', value: 'value2' }], proxy: { type: 'ajax', ... encodeFilters: function(filters) { var min = [], length = filters.length, i = 0; for (; i < length; i++) { min[i] = { field: filters[i].property, value: filters[i].value }; } return this.applyEncoding(min); } } });
-
4 Sep 2012 2:43 AM #2
Try this:
Code:var store = Ext.create('Ext.data.Store', { ... remoteFilter: true, filters: [{ property: 'field1', value: 'value1' },{ property: 'field2', value: 'value2' }], proxy: { type: 'ajax', ... encodeFilters: function(filters) { var min = [], length = filters.length, i = 0; for (; i < length; i++) { min[i] = { field: filters[i].property, value: filters[i].value }; } return this.applyEncoding(min); } } });
-
4 Sep 2012 4:10 AM #3
I test it and it works quite well !
Thanks for your answer !
I've found an alternative solution (comments on FiltersFeature helps me). I override function buildQuery and change key name field by property :
Code:tmp.push(Ext.apply( {}, {property: f.field}, f.data ));Last edited by badenski; 6 Sep 2012 at 6:25 AM. Reason: alternative solution
-
14 Jan 2013 12:01 AM #4
vietits, your solution solved my problem where my remote filters were not working at all... no idea why, but with your change it finally started working (though in my case it was added to data.Model, not data.Store).
No idea how it works exactly (or why it doesn't work otherwise), but this was a life-saver. (FiltersFeature didn't work for some reason for me due to a conflict with some form features).
Thanks!


Reply With Quote