I'm calling an oData v2 service with an $expand parameter so the url looks like this:
https://host/odata/v2/myEntity?$expand=key4
and I am returned an oData json object which looks like this:
{
"d": {
"results": [
{
"key1": "val1",
"key2": "val2",
"key3": "val3",
"key4": {
"results": [
{
"key5": "val5",
"key6": "val6",
"key7": "val7"
}
]
}
}
]
}
}
Once I receive the oData object, in my controller.js I create a JSONModel object like so and assign it to the viewModel:
var oJson = new sap.ui.model.json.JSONModel(oData);
this.getView().byId("tableId").setModel(oJson, "myModel");
Next, in my View.xml I have a table with the id "tableId" which binds this myModel as so:
<Table id="tableId" items="{path: 'myModel>/results' }">
With the above I am able to retrieve the values for key1, key2 and key3 in the table by doing:
<Text text="{myModel>key1}" />
But I cannot get the values for the results array under key4 to access key5, key6 and key7. How do I achieve this please?
You mentioned aggregation binding . How do you do that to bind the values of everything under
key4
to the same table?
Depends on how you'd like display the key4
values. Since .../key4/results
is a collection, same as /d/results
, you could, for example, create another table / list control that shows items from the key4
that was selected from the 1st table via context binding . It's not possible to bind key4
in the same table.
About the aggregation concept in general, see answers from Aggregation in SAP UI5 .
For aggregation binding , in particular with ODataModel
and <NavigationProperty>
/ $expand
, the following answers might help:
No need to use a JSONModel
for this case.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.