SAPUI5扩展清单中的模型 [英] SAPUI5 Expand the model in the manifest

查看:78
本文介绍了SAPUI5扩展清单中的模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想向manifest.json添加一个新模型. 该模型应该进行扩展.

I want to add a new model to the manifest.json. The model is supposed to be expanded.

https://myPath/services/myService.xsodata/SubPath?$expand=CustomerRef

因此定义了数据源:

"dataSources": {
    "mainService": {
        "uri": "/myPath/services/myService.xsodata/",
        "type": "OData",
        "settings": {
            "odataVersion": "2.0",
            "localUri": "localService/myService.xsodata/metadata.xml"
        }
    }

模型已定义:

"models": {
    "Customer": {
        "type": "sap.ui.model.odata.v2.ODataModel",
        "settings": {
            "useBatch": "false"
        },
        "dataSource": "mainService"
    }

如何将扩展添加到模型中?

How can I add the expand to the model?

推荐答案

不能在模型定义本身中扩展数据. expand参数用于将视图和数据之间的绑定定义为

The data cannot be expanded in the model definition itself. The expand parameter is to be used where the binding between the view and data is defined as mentioned in the documentation:

某些参数不能包含在每个请求中,而只能添加到特定的聚合或元素绑定中,例如$ expand或$ select.为此,绑定方法提供了传递参数映射的选项,然后将其包含在对此特定绑定的所有请求中.

Some of the parameters must not be included in every request, but should only be added to specific aggregation or element bindings, such as $expand or $select. For this, the binding methods provide the option to pass a map of parameters, which are then included in all requests for this specific binding.

例如(摘自 https://embed.plnkr.co/wAlrHB/):

<List items="{
  path: 'odataModel>/Products',
  parameters: {
    expand: 'Category, Supplier',
    select: 'ProductName, UnitsInStock, Category/CategoryName, Supplier/Country'
  },
  sorter: [
    {
      path: 'Category/CategoryName',
      group: true
    }
  ],
  filters: [
    {
      path: 'Supplier/Country',
      operator: 'EQ',
      value1: 'UK'
    }
  ]
}">
  <ObjectListItem title="{odataModel>ProductName}" number="{odataModel>UnitsInStock}"/>
</List>

绑定(不是模型)将

The binding (not the model) will then send a request ...

对后端的请求由列表绑定(ODataListBinding)触发

Requests to the back end are triggered by list bindings (ODataListBinding)

...,并在UI5后面附加相应的参数:

... with the respective parameters appended by UI5:

"http://services.odata.org/V2/Northwind/Northwind.svc/Products?$skip=0&$top=100&$orderby=Category/CategoryName%20asc&$filter=Supplier/Country%20eq%20%27UK%27&$expand=Category%2c%20Supplier&$select=ProductName%2c%20UnitsInStock%2c%20Category%2fCategoryName%2c%20Supplier%2fCountry"

==> 结果

这篇关于SAPUI5扩展清单中的模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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