For example, say I have a server API for loading people that handles requests like this: GET /people/?id=101,329,27
I’d like to build a Store (probably a custom class that extends Ext.data.Store) which–assuming it has a list of people IDs–causes the proxy to make a request like the one shown above so that the returned data is only for that subset of persons.
I saw the documentation regarding remote filtering, but my concern is that to use it I would first need to call store.load() which would load all persons, then call filter() to do remote filtering. I’d like to just load the subset of persons the first time.
Thanks for any advice!
Found a solution (although still open to hearing other ideas).
First, you can call a store’s load() function with a config object that will be passed to an operation. The API docs for Ext.data.Operation make it clear that one of the config options is for an array of Filter objects, so you can do this:
This results in a request where the URL querystring contains
?filter=[{"property"%3Aid%2C"value"%3A100,200,300}](in other words, a URL-encoded version of[{ property: 'id', value: '100,200,300'}]).You can also just call
myStore.filter('id', '100,200,300')without having called.load()first. Assuming you have remoteFilter=true in your store, this will make a request with the same query params shown agove.Sidenote: you can change the keyword used for ‘filter’ by configuring the ‘filterParam’ config option for the proxy. For example, if filterParam=q, then the querystring shown above changes to:
?q=[{"property"%3Aid%2C"value"%3A100,200,300}]Second, you can control “structure” of the filter in the querystring. In my case, I didn’t want something like filter={JSON}, as shown above. I wanted a querystring that looked like this:
?id=100,200,300For this I needed to extend a proxy and override the default getParams() function: