PDA

View Full Version : [OPEN] Ext.util.Filter Operators in store requests



vela1606
10 Apr 2013, 3:38 PM
I not sure if this is a bug or working as intended, but I think the store should send the filter operator if remoteFilter (http://docs.sencha.com/ext-js/4-2/#!/api/Ext.data.Store-cfg-remoteFilter) is true. This way you can correctly filter using your server code.

here is the code 'Ext.data.proxy.Server'


encodeFilters: function(filters) {
var min = [],
length = filters.length,
i = 0;


for (; i < length; i++) {
min[i] = {
property: filters[i].property,
operator: filters[i].operator,
value : filters[i].value
};
}
return this.applyEncoding(min);
}


This will send the operator set in 'Ext.util.Filter' or null which is the default value.

slemmon
11 Apr 2013, 9:21 AM
I tested just now with 4.2 with a grid with remoteSort on a store and it looked like it sent the configured filter over to the server. It looked like this in the query params:

filter:
[{"property":"name","value":"Lisa"}]


You're not seeing it sent in your test though?

vela1606
11 Apr 2013, 9:40 AM
You are right... but what I am saying is if remoteFilter = true, the request should be:

[{"property":"name","operator":"=","value":"Lisa"}]

This way you can use the server side code to correctly filter the data.
Currently the operator is not send, therefor is impossible for the server to determine/control how to filter the data.
eventho I am setting the filter like this:


filters:[{
property: 'status',
operator:'=',
value: 'filtervalue'
}]


The goal is to dynamically use Sencha store to determine how you want the server to filter the data.

vela1606
11 Apr 2013, 10:04 AM
To give you a bit of background...

We are developing MatchaConnect (https://github.com/MatchaConnect/MatchaConnect) a microORM for sencha that uses the existing Sencha Models and Ext.Direct to manage the database structure and all the CRUD requests.

We are currently implementing this in GaiaEHR (http://gaiaehr.org/) and so far is working like a champ :-)

So basically I want to send a Ext.Direct request directly to MatchaConnect with the proper operator and let Matcha filter the data without having to write any extra PHP code :-)

Right now I am overriding the the Ext.data.proxy.Server class to make this happen, like this....


Ext.override(Ext.data.proxy.Server, {
encodeFilters: function(filters) {
var min = [],
length = filters.length,
i = 0;


for (; i < length; i++) {
min[i] = {
property: filters[i].property,
operator: filters[i].operator,
value : filters[i].value
};
}
return this.applyEncoding(min);
}
});


I think the operators (=,<=,>=,!=, etc... etc...) are necessary if the remoteFilter = true, Dont you think? :D

slemmon
11 Apr 2013, 4:00 PM
Ahh.... Ok, I'm with you now. Thank you for elaborating. I submitted a feature request on your behalf including the override you're currently using.

Thanks for the suggestion!

ssamayoa
16 Jan 2014, 6:20 PM
Ahh.... Ok, I'm with you now. Thank you for elaborating. I submitted a feature request on your behalf including the override you're currently using.


Just bumped with this.

I personally think that is a bug and not a feature request.

ETA for this fix?

Regards.

vela1606
16 Jan 2014, 6:50 PM
Thats what I thought too... I don't see how you can correctly remotely filter the data if an operator is not send to the server

At least the above override fix the issue.
But, if a filter operator is not set, then operator = null

sujam
16 May 2016, 11:00 AM
Hi,
Do you know how can I extract this array from the store object?

I am trying the following code, but it's not working. Do I need to form array like this myself (

filter:
[{"operator":"gt","value":2222,"property":"qty_raw"}]
) or is it possible to get it directly? :
var filters = store.getFilters().items;

Thanks!