Hi experts,
I am developing a UI5 web application which consumes oData collections.
One of these oData collection is fetched using get_expanded_entityset method which I implemented in my oData service
The get_expanded_entityset method returns both header and line items in the form of a collection of items [in my case it is called 'toPosition' navigation property]
Now I have a data table which is binded to that oData method but I am not able to get the single line items data displayed into each cell.
This is the data bind code I use
var oModelCarrier = new sap.ui.model.odata.ODataModel('/sap/opu/odata/sap/Z_COLL_PORTAL_SRV',{json:true});
var tableCarrier = sap.ui.getCore().byId("carrierInvoiceSub-carrierSubmission--carrierTable");
tableCarrier.setModel(oModelCarrier);
oModelCarrier.setCountSupported(false);
tableCarrier.bindRows( {path: '/fileRepositorySet',
filters : [ new sap.ui.model.Filter("fileId", sap.ui.model.FilterOperator.EQ, fileid) ],
parameters : {expand: 'toPosition'}
});
and this is the table view part
<table:Table id="carrierTable" enableGrouping="true" enableSorting="true">
<table:title><Textview text="Carrier Shipments [Uploaded]"></Textview></table:title>
<table:columns>
<table:Column>
<Label text="Invoice Num."/>
<table:template>
<layout:VerticalLayout content="{toPosition/results}" xmlns:layout="sap.ui.layout">
<layout:content>
<TextView text = "{invoiceNumber}" />
</layout:content>
</layout:VerticalLayout>
</table:template>
</table:Column>
<table:Column>
<Label text="Container Type"/>
<table:template>
<layout:VerticalLayout content="{toPosition/results}" xmlns:layout="sap.ui.layout">
<layout:content>
<TextView text = "{containerType}" />
</layout:content>
</layout:VerticalLayout>
</table:template>
</table:Column>
</table:columns>
</table:Table>
and most important this is the oData response I get from my service calling get_expanded_entityset
can anyone help me how to get collection data displayed on table cells ?
it seems the response I get is correct containing all the data I need for my application [pls see attachment table_response.png ].
please be patient with me, I am learning oData / UI5 technology so I am not an expert
best regards,
claudia
Request clarification before answering.
Hi Claudia,
Check this working sample, where I used your JSON response: JS Bin - Collaborative JavaScript Debugging
Few points -
1. I have added comments in the code, hope you will understand.
2. Since you told me fileId is a user input, so the logic is handled such a way where the fileid is must to filter the item details.
3. In text field control placed down the table, try to provide this fileId value carrierfile20150923174312, then the table data will get updated with respect to that fileId.
Regards,
Sai Vellanki.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sai,
I've implemented your solution into my web application.
But data into table rows is still not populating with data I get correctly from oData response.
I am now debugging the code part you passed to me.
In particular I think there is something about the oItems object which is different from the one hardcoded in the aData model into your example.
See my result for oItems here
Do you think there is something wrong about this structure I get back from oData ?
Maybe the "0", "1", "2", etc. attributes are not binding the data as expected ?
Many thanks in advance,
Kind regards
claudia
Hi Claudia,
Your items is in the array structure, Set the model and bind it to table rows like below -
sap.ui.getCore().getModel().setProperty("/modelData/itemData", oItems[0]); //Set the Model
this.getView().byId("carieerTable").bindRows({path:"/modelData/itemData"}); //Bind the Model to table rows.
Regards,
Sai Vellanki.
Sai,
Now your solution is working fine into my application case.
Data rows have been populated with items data as expected.
Really many thanks and thank you for your patiente.
I am learning SAPUI5 so I am not an expert as you are,
but at least now I begin to understand a little more reading your suggestion step by step.
Kind regards,
Claudia
Message was edited by: Claudia Bressi
| 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.