如何在 UI5 中默认禁用 V2 OData $batch 请求? [英] How to disable V2 OData $batch request by default in UI5?

查看:65
本文介绍了如何在 UI5 中默认禁用 V2 OData $batch 请求?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 SAPUI5 在 Web IDE 中制作了一个 Master-Detail 应用程序.

I made a Master-Detail application in Web IDE with SAPUI5.

我将我的应用程序连接到 OData 服务 (V2).连接参数已存储在 manifest.json 中.

I connected my application to an OData service (V2). The connection parameters have been stored in manifest.json.

我想阻止我的 UI5 应用程序使用 $batch 请求.

I want to prevent my UI5 application from using $batch requests.

我知道如何使用以下代码禁用特定请求的批处理请求:

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

var oDataModel = this.getModel(); // sap.ui.model.odata.v2.ODataModel
oDataModel.setUseBatch(false);

但问题是我不能在 onInit 函数中使用它.

But the problem is that I can not use this in onInit function.

我可以在 manifest.json 中设置一些参数来禁用批处理请求,即使程序正在加载它也不使用 $batch 吗?

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?

推荐答案

您应该能够将参数 useBatch 添加到您的模型设置中.根据文档(部分/sap.ui5/models) 这些设置将传递给构造函数.

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

{
  "sap.ui5": {
    "models": {
      "yourV2ODataModel": {
        "dataSource": "yourDataSource",
        "settings": {
          "useBatch": false
        }
      }
    }
  }
}

onInit 中组件模型的可用性已经在这里讨论了几个 .请参阅应用程序 init 进程以了解它们不可用的原因.

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.

这篇关于如何在 UI5 中默认禁用 V2 OData $batch 请求?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆