How to disable Odata Batch request by default in SAPUI5?

user7383443 picture user7383443 · Feb 2, 2017 · Viewed 12k times · Source

I made a Master-Details application in Web IDE for SAPUI5.

I connected my application to an OData service. The connection parameters has been stored in manifest.json.

I want to prevent my UI5 application from using batch request when it requests data from OData endpoint.

I know how to use the following code to disable batch request for a particular request:

var oDataModel = this.getModel();
oDataModel.setUseBatch(false);

But the problem is that I can not use this in onInit function. Can I set some parameter in manifest.json to disable batch request in general and even when the program is loading it does not use batch?

Answer

matbtt picture matbtt · Feb 2, 2017

You should be able to add parameter useBatch to the settings of your model. According to the documentation (section models) these settings will be passed to the constructor.

"models": {
    "yourModel": {
        "dataSource" : "yourDataSource",
        "settings" : {
          "useBatch" : false
        }
    }
}

The availability of component models in onInit has been discussed here several times. See the application init process to see why they are not available.