I'm refactoring code to communicate with RubyOnRails using the RestDataSource class. I have this already working using transformRequest, but I want to improve the code if possible. Therefore, I have two questions:
- By default, when there are two sort fields, the query string generated is &_sortBy=field1&_sortBy=-field2. In Rails only the last request parameter is returned. Ideally, I would like to have a comma separated argument (&_sortBy=field1,-field2) or an array, which can be achieved by suffixing the argument names with "[]" (&_sortBy[]=field1&_sortBy[]=-field2). I now use transformRequest() to achieve this, but was wondering if there's a setting that allows me to change the argument name.
- I've probably asked this before, but can't find the post(s) for it anymore. I would like an easy way to send the field names visible in a grid so that the server only needs to query those fields and return only that data (optimization). I now set a dataProperties.requestProperties.params.fields option in the grid's init() method, but I read something about an "outputs" option in DSRequest, but can't get my finger around it how to configure this exactly.
The way I now fix this in the grid is like this:
Code:this.dataProperties ||= {}; this.dataProperties.requestProperties ||= {}; this.dataProperties.requestProperties.params ||= {}; this.dataProperties.requestProperties.params.fields ||= this.fields.getProperty('name').join(',');
Comment