on 08-14-2015 3:46 AM
Hi expert,
How to load odata json with $expand parameter and bind deep entity data to list control in master page?
With TCode:/IWFND/GW_CLIENT,I can use url "/sap/opu/odata/SAP/ZWPURCHASE_REQUEST_SRV/HeaderSet?$expand=TextLines,Items/ServiceLines,Items/Accounts,Items/AddrDeliverys,Items/TextLines&$format=json" to get the json data,
But I don't know how to get json data and bind deep entity json data to list control in master page in fiori app.
thank you.
best regards,
felix.
Hi Felix,
Try this
Master.View.xml
-------------------------------------
<ObjectHeader title="{Items>/0/Mblnr}" tooltip="{i18n>detailArticleDoc}">
<attributes>
<ObjectAttribute text="{Items>/0/Mjahr}" tooltip="{i18n>detailArticleDocYear}"/>
<ObjectAttribute text="" />
</attributes>
</ObjectHeader>
<Table id="idItemTable" inset="false" mode="MultiSelect"
items="{Items>/0/HeaderItemNP/results/}">
<headerToolbar>
<Toolbar>
<Label text="Item(s)"></Label>
</Toolbar>
</headerToolbar>
<columns>
<Column minScreenWidth="Tablet" hAlign="Left">
<Text text="{i18n>detailArticle}" />
</Column>
<Column minScreenWidth="Tablet" hAlign="Center">
<Text text="{i18n>detailPONo}" />
</Column>
<Column minScreenWidth="Tablet" hAlign="Right">
<Text text="{i18n>detailQtyRec}" />
</Column>
<items>
<ColumnListItem>
<cells>
<ObjectIdentifier title="{Items>Matnr}" text="{Items>Maktx}" />
<ObjectIdentifier title="{Items>Ebeln}" text="{Items>Ebelp}" />
<Text text="{Items>Menge}" />
</ColumnListItem>
</items>
</Table>
Master.controller.js
-------------------------------------------------
var fnSuccess = function(data) {
var oModel = new sap.ui.model.json.JSONModel(data);
detailView.getView().setModel(oModel, "Items");
};
var fnError = function(data) {
console.log('Error');
};
var params = "$expand=HeaderItemNP&$filter=Mblnr eq '" + oEvent.Mblnr + "' and Mjahr eq '" + oEvent.Mjahr + "'";
* read the model here with HeaderSet
},
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think I get the answer:
Component.js
var sServiceUrl = "/sap/opu/odata/SAP/ZWPURCHASE_REQUEST_SRV/";
var oModel;
if (window.location.hostname == "localhost") {
oModel = new sap.ui.model.odata.ODataModel("proxy" + sServiceUrl, true, "CHENZHI", "123456");
} else {
oModel = new sap.ui.model.odata.ODataModel(sServiceUrl, true);
}
oModel.setHeaders({
"X-Requested-With" : "JSONHttpRequest",
"Content-Type" : "application/json",
"DataServiceVersion" : "2.0",
"Accept-Language" : "zh-CN"
});
// set json model as default
oView.setModel(oModel);
Master.view.xml
<core:View
controllerName="cnooc.servpr.approve.view.Master"
xmlns="sap.m"
xmlns:core="sap.ui.core" >
<Page title="{i18n>MasterTitle}" >
<List
id="list"
mode="{device>/listMode}"
select="handleListSelect"
items="{path: '/HeaderSet', parameters: {expand: 'TextLines,Items/ServiceLines,Items/Accounts,Items/AddrDeliverys,Items/TextLines'}}" >
<ObjectListItem
type="Navigation"
press="handleListItemPress"
title="{PreqNo}"
number="{SN}"
numberUnit="{PrType}">
<attributes>
<ObjectAttribute text="{ApplicationNumber}" />
<ObjectAttribute text="{ApplicationID}" />
</attributes>
</ObjectListItem>
</List>
</Page>
</core:View>
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
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.