Why can I give items as property?


Why can I give items as property?



The Table is extended from the ListBase. On the Table, I can you use items aggregation from ListBase as a property like as following:


<Table inset="false" items="{ path: '/ProductCollection', sorter: { path: 'Name' } }">



Why can I use items as a property, although is defined as aggregation?


items





Not sure what exactly the question is.. Are you asking what items="{...}" does? Or how the framework handles items in the background, thus "why" it works? This question is missing some context.
– Boghyon Hoffmann
2 days ago


items="{...}"


items




2 Answers
2



In UI5, there are basically two ways of filling an aggregation. One is by adding the elements directly, and the other is to bind them to a model.



Your example shows the latter case, where the items aggregation is bound to the collection /ProductCollection in your model.


items


/ProductCollection



An aggregation binding consists of two parts in XML views, one is the actual binding with the "property" as you did, and the other is to specify the "template" which is used for each element in the collection.



This is also explained further in the documentation:


<mvc:View
controllerName="sap.ui.sample.App"
xmlns="sap.m"
xmlns:mvc="sap.ui.core.mvc">
<List id="companyList" items="{/companies}">
<items>
<StandardListItem
title="{name}"
description="{city}"
/>
</items>
</List>
</mvc:View>



The List element has both an items attribute and a nested items element:


items


items


items="{/companies}"


companies


companies


items


StandardListItem





Writing "items=..." in the XML is the same as writing "bindItems(..." or "bindAggregation('items',..." in JS. The framework knows that it is an aggregation and that you are binding the path '/ProductCollection' from your unnamend odata model to it.



As Ronnie mentioned, in the binding there are properties like 'path' or 'sorters'. You can check it here https://sapui5.hana.ondemand.com/#/api/sap.ui.base.ManagedObject/methods/bindAggregation
The object oBindingInfo is the one.






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

how to run turtle graphics in Colaboratory

Export result set on Dbeaver to CSV