REST-style url when using FilteringSelect+JsonRest

84 views Asked by At

JsonRest seems to be designed to user rest-style urls (e.g. /path/keyword)

When used with FitleringSelect, the query is path/?searchAttr=keyword

Any way I can set FilteringSelect to pass just pass the keyword to the JsonRest store?

1

There are 1 answers

0
Simon On

The FilteringSelect passes an object to the store/JsonRest as the query. This is automatically converted to a query string in JsonRest.query(). If you pass a string to the store's query method, then it is appended to the url. So a hacky solution is to modify the the query property of the FilteringSelect before it is passed to the store by monkey patching the _startSearch() method, e.g.:

var myFilter = new FilteringSelect(...),
   oldStartSearch = myFilter._startSearch;

myFilter._startSearch = function(text) {
    this.query = text;
    oldStartSearch.call(this, text);
};