on 03-08-2019 1:34 PM
Dear UI5 experts,
Dear Jun Wu, I hope you could help me out with this.
I have 2 entites/entitySets (Z001, ZAttachment) and 1 association (Z001ToZattachment) which describes the connection between them and has a 0..n cardinality. The backend coding is done and everything works fine.
Z001 entity has the following fields: OrderID, OrderName
ZAttachment has: OrderID, FileGuid, FileName
In my XML view I would like to bind both the fields from Z001 and the rows/records of Zattachment into the UploadCollection. It looks something like this:
<Input value="{OrderId}"></Input>
<Input value="{OrderName}"></Input>
<UploadCollection items="{path:'Z001Set', parameters: { expand: 'Z001ToAttachment' }}">
<items>
<UploadCollectionItem fileName="{Z001ToAttachment/FileName}"></UploadCollectionItem>
</items>
</UploadCollection>
In my controller I create the Entry like this:
var Z001 = this.getModel().createEntry("/Z001Set", {
}).bind(this);
this.getView().setBindingContext(Z001);
But the upload collection wont work, console says: "Missing template for factory function for aggregated items of Element sap.m.UploadCollection". I know i could not bind the data right, the question is how shall it be done?
Thanks
Tu
Hi Tu,
your binding looks a little bit off.
I think you want to bind the attachments of an Entry "Z001Set", is that right?
In that case you have to do the binding like this:
<UploadCollection items="{Z001ToAttachment}">
<items>
<UploadCollectionItem fileName="{FileName}"></UploadCollectionItem>
</items>
</UploadCollection>
Small addendum: Z001ToAttachment has to be an array. I don't think the associations get created with createEntry so you have to add them manually.
Hope this helps. Could be wrong as I didn't try this out by myself.
Greetings
Sebastian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Tu,
the proper way is to create Z001Set first and save it.
When you read the entity with expand the next time you get an empty array for Z001ToAttachment.
In that case your binding works (but should not show anything because the array is empty).
When there is an persisted Entity Z001Set you are able to create an entity for ZAttachmentSet with reference to your Z001Set Entity.
After that attachments will be displayed.
I strongly recommend that you do it this way. Working with non persisted entities and associations is ugly, time consuming and frustrating.
Greetings
Sebastian
User | Count |
---|---|
84 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.