PDA

View Full Version : Sorter[]/Filter[] are not added to Ext.data.Operation. Bug?



Kah0ona
3 Feb 2012, 8:03 AM
Hello,

I am using the following Store, in combination with the following Operation to fetch data from a proxy (fetch_proxy.php). The sorters and filters array should add parameters to the url of this proxy. Except it doesn't work, the default parameters are appended to the url, not my 'overriding' config, if I look at the resulting GET request.

Am I doing something wrong, or is this a bug?

In other words: how to add parameters to the url of a proxy?


Ext.define('myApp.store.Combined', {
extend: 'Ext.data.Store',
config : {
model: 'myApp.model.Shops',
proxy : {
type: 'ajax',
url: 'fetch_proxy.php',
reader: 'json'
}
},

});


Ext.define('myApp.store.ListOperation',{
extend: 'Ext.data.Operation',
config:{
model: 'myApp.model.Shops',
action: 'read',
sorters: [
new Ext.util.Sorter({
property: 'distance',
direction: 'ASC'
})
],
filters: [
new Ext.util.Filter({
property: 'lng',
value: 0
}),
new Ext.util.Filter({
property: 'lat',
value: 0
})
]
}


});


//load it, in app.js...
myApp.combinedStore = Ext.create('myApp.store.Combined');
myApp.listOperation = Ext.create('myApp.store.ListOperation');

myApp.combinedStore.load(myApp.listOperation);


This method did work in Sencha touch 1, but not in Touch 2.

Any ideas?

mitchellsimoens
3 Feb 2012, 8:21 AM
Why aren't you adding the sorter and filter to the store?

Kah0ona
3 Feb 2012, 8:27 AM
Thanks for your quick response.

We don't add it to the Store because the filtering/sorting is done on the server behind the proxy.

So we want Sencha to make a GET request like this:
fetch_proxy.php?filters=[{......}]&sort=[{....}]

But now it just does the default request with default start, limit, etc, eventhough we tried to override it with our custom sorters/filters (this url is generated by Sencha, instead of one with our filters/sorters: http://m.myapp.nl/beta/fetch_proxy.php?_dc=1328286627006&page=1&start=0&limit=25&action=read)
This used to work in Sencha 1.

Bottom line: We can't load everything in Sencha, and then filter it locally, so we want to send parameters to the server.

How can we achieve this?

mitchellsimoens
3 Feb 2012, 8:36 AM
You can use remoteSort and remoteFilter

Kah0ona
3 Feb 2012, 8:46 AM
Thanks that worked great! So, should the docs of Operation be updated? Because it still talks abou filters / sorters.

mitchellsimoens
3 Feb 2012, 8:56 AM
No really. It's good that people understand that there is a class there. It really should be marked private IMO.