SAPUI5 Expand the model in the manifest

前端 未结 1 1309
醉梦人生
醉梦人生 2020-12-21 17:24

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
<         


        
相关标签:
1条回答
  • 2020-12-21 17:53

    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:

    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.

    E.g. (from 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 ...

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

    ... 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"
    

    ==> result

    0 讨论(0)
提交回复
热议问题