負載的OData我已經配置的信息用於從SAP UI5訪問我OData服務中在manifest.json失敗時在SAPUI5
{
"sap.app": { ...
},
"dataSources": {
"Test": {
"uri": "/sap/opu/odata/sap/ZHCM_SRV/",
"type": "OData",
"settings": {
"odataVersion": "2.0",
"localUri": "localService/metadata.xml"
}
}
} ...
"sap.ui5": {
"rootView": {
"viewName": "test.view.App",
"type": "XML",
"id": "app"
}, ...
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "test.i18n.i18n"
}
},
"Test": {
"type": "sap.ui.model.odata.v2.ODataModel",
"settings": {
"defaultOperationMode": "Server",
"defaultBindingMode": "TwoWay",
"defaultCountMode": "None"
},
"dataSource": "Test"
}
},
"routing": { ...
}
以我Component.js我有:
init: function() {
UIComponent.prototype.init.apply(this, arguments);
this.getRouter().initialize();
this.setModel(models.createDeviceModel(), "device");
// I get the Url from configuration in Manifest.json
var sServiceUrl = this.getMetadata().getManifestEntry("sap.app").dataSources["Test"].uri;
// I create the OData
var sabModel = new sap.ui.model.odata.v2.ODataModel(sServiceUrl);
// Load the MetaData.
sabModel.getServiceMetadata();
// Binding to the Model.
this.setModel(sabModel, "Sabbatical");
時我正在檢查oModel我可以看到我已經實例化模型,但它是空的,沒有數據...你有這種行爲嗎?任何建議?
非常感謝! CBR
謝謝米歇爾, 我發送一個結構(1陣列),我想不加載表或列表來管理它。 我會看看你告訴我的解決方案。 非常感謝! –