Skip to content

Instantly share code, notes, and snippets.

@augustine-tran
Created December 7, 2010 13:53
Show Gist options
  • Save augustine-tran/731799 to your computer and use it in GitHub Desktop.
Save augustine-tran/731799 to your computer and use it in GitHub Desktop.
replace arguments by hack to add empty params.filters to request for buildUrl
/**
* We need to add a little processing to the normal buildRequest. In YQL we send an SQL-like
* query statement - in this case using the search query above. To honor the filters applied
* by the user, we pull those out in this function and apply them to the search XTemplate.
* Finally, we modify the url to add this generated query and any other required parameters.
*/
buildRequest: function(operation) {
var hack = Ext.apply({params: {filters: []}}, arguments);
var request = Ext.data.KivaProxy.superclass.buildRequest.apply(this, [hack]),
queryTpl = this.queries.search,
filters = operation.filters || [],
filterData = {};
Ext.iterate(filters, function(filter) {
filterData[filter.property] = filter.value;
});
delete request.params.filters;
Ext.applyIf(request.params, {
format: 'json',
q: queryTpl.applyTemplate(filterData)
});
request.url = Ext.urlAppend(request.url, Ext.urlEncode(request.params));
return request;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment