Hi,
I've created a GW service structured with one main element and a few associations. These work fine in the browser:
I'm now trying to use these in my UI5 application. I set the application context to be (for example) /AssetCollection('1234') and can display elements of this entity using syntax like:
<Text text="{Id}"/>
I can also bind the associated entity collection to a List successfully using syntax:
<List headerText="Alerts" items="{AssetSummaryAlertSet}">
<items>
<ObjectListItem number="{Aoid}" title="{Title}">
<attributes>
<ObjectAttribute text="{Name}"/>
<ObjectAttribute text="{Address}"/>
</attributes>
</ObjectListItem>
</items>
</List>
My issue is displaying elements of associated entities where the relationship is 1..1:
I naively thought I could do something like:
<Text text="{StockCond/Quantity}"/>
This doesn't display anything and the corresponding endpoint is not called at all.
Looking at the binding in the Control Tree in the diagnostic popup tells me the path is: Stock/Quantity (invalid)
I get the same invalid error for my list however and that does display data!
Is this type of binding possible in UI5 or do I need to flatten my service and use something like $expand?
Thanks,
Gregor
Request clarification before answering.
Just an inkling, but as an alternative to $expand, you might try an explicit binding specification on the Text control
<Text binding="Stock" text="Quantity" />
ISTR this should fire an OData call to fetch the associated entity, but I could be dreaming...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi DJ
I think the following should work, the binding has to be relative to existing context
<Text binding="{/Stock}" text="{Quantity}" />
Couldnt get it working though see JS Bin
<commons:TextField binding="{/Supplier}" value="{CompanyName}" />
should return
http://services.odata.org/V3/Northwind/Northwind.svc/Products(1)/Supplier/CompanyName
jsp
Thanks John and DJ, I have been struggling with this one for hours!
I've ended up with
<Text binding="{StockCond}" text="{Quantity}" /> (dropping the leading / to make it relative rather than absolute path I think?)
I really appreciate the help. Your contributions to the UI5 community and beginners like myself are astonishing!
Hi Gregor
Your on the right track, see JSBin HTML example, to expand try
{path:'/AssetCollection', parameters:{expand:'Stock'}}
hth
jsp
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.