如何从我的控制器 SapUI5 访问 MockData
How to get access of MockData from my Controller SapUI5
我需要你的帮助。我试图让模拟数据来填充我的简单表格但没有成功。
我已经按照 sap Hana 的例子来配置我的模拟服务器。
模拟服务器工作正常,但我不知道如何在我的视图控制器上获取模拟数据。
请你能帮帮我吗?
她是我的差异代码
模拟数据 (Informations.js)
[{
"Destination": "12D13E456S7",
"Customer": "Uni Mannheim",
"Position": "1237",
"TaskNr": 87654321,
"Adress": "COL 1234",
"Remark": "Ordinateur non utilisable",
"Order": "A4585Qwe84"
}]
manifest.json
{
"_version": "1.32.0",
"sap.app": {
"id": "Informations",
"type": "application",
"i18n": "i18n/i18n.properties",
"applicationVersion": {
"version": "1.0.0"
},
"dataSources": {
"InformationRemote":{
"uri": "/",
"type": "OData",
"settings": {
"odataVersion": "2.0",
"localUri": "localService/metadata.xml"
}
}
},
"title": "{{appTitle}}",
"description": "{{appDescription}}",
"resources": "resources.json",
"ach": "ach"
},
"sap.ui": {
"technology": "UI5",
"icons": {
"icon": "sap-icon://task",
"favIcon": "",
"phone": "",
"phone@2": "",
"tablet": "",
"tablet@2": ""
},
"deviceTypes": {
"desktop": true,
"tablet": true,
"phone": true
}
},
"sap.ui5": {
"flexEnabled": false,
"rootView": {
"viewName": "Informations.view.Main",
"type": "XML",
"async": true,
"id": "Main"
},
"dependencies": {
"minUI5Version": "1.93.0",
"libs": {
"sap.ui.core": {},
"sap.m": {},
"sap.ui.layout": {}
}
},
"contentDensities": {
"compact": true,
"cozy": true
},
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "Informations.i18n.i18n"
}
},
"":{
"dataSource": "InformationRemote",
"preload": true
}
},
"resources": {
"css": [
{
"uri": "css/style.css"
}
]
},
"routing": {
"config": {
"routerClass": "sap.m.routing.Router",
"viewType": "XML",
"async": true,
"viewPath": "Informations.view",
"controlAggregation": "pages",
"controlId": "app",
"clearControlAggregation": false
},
"routes": [
{
"name": "RoutevwInformation",
"pattern": "RoutevwInformation",
"target": ["TargetvwInformation"]
}
],
"targets": {
"TargetvwInformation": {
"viewType": "XML",
"transition": "slide",
"clearControlAggregation": false,
"viewId": "Main",
"viewName": "Main"
}
}
}
}
}
拜托,我该怎么做才能看到模拟数据,我应该在 viewController 中实现一些东西吗?
我真的不知道该怎么做。
提前致谢
如果您使用的是 WebIDE,请务必设置正确的配置。
首先 select“运行 配置”,当您右键单击您的项目时。
弹出窗口出现,您可以在其中创建新的 运行 配置。在那里,您需要 select 复选框“运行 with mock data”。
现在您应该可以启动 运行 配置:
我知道该怎么做我只需要做这样的事情。
var oModel = new sap.ui.model.odata.v2.ODataModel("myUrl");
sap.ui.getCore().setModel(oModel);
我需要你的帮助。我试图让模拟数据来填充我的简单表格但没有成功。 我已经按照 sap Hana 的例子来配置我的模拟服务器。
模拟服务器工作正常,但我不知道如何在我的视图控制器上获取模拟数据。 请你能帮帮我吗? 她是我的差异代码
模拟数据 (Informations.js)
[{
"Destination": "12D13E456S7",
"Customer": "Uni Mannheim",
"Position": "1237",
"TaskNr": 87654321,
"Adress": "COL 1234",
"Remark": "Ordinateur non utilisable",
"Order": "A4585Qwe84"
}]
manifest.json
{
"_version": "1.32.0",
"sap.app": {
"id": "Informations",
"type": "application",
"i18n": "i18n/i18n.properties",
"applicationVersion": {
"version": "1.0.0"
},
"dataSources": {
"InformationRemote":{
"uri": "/",
"type": "OData",
"settings": {
"odataVersion": "2.0",
"localUri": "localService/metadata.xml"
}
}
},
"title": "{{appTitle}}",
"description": "{{appDescription}}",
"resources": "resources.json",
"ach": "ach"
},
"sap.ui": {
"technology": "UI5",
"icons": {
"icon": "sap-icon://task",
"favIcon": "",
"phone": "",
"phone@2": "",
"tablet": "",
"tablet@2": ""
},
"deviceTypes": {
"desktop": true,
"tablet": true,
"phone": true
}
},
"sap.ui5": {
"flexEnabled": false,
"rootView": {
"viewName": "Informations.view.Main",
"type": "XML",
"async": true,
"id": "Main"
},
"dependencies": {
"minUI5Version": "1.93.0",
"libs": {
"sap.ui.core": {},
"sap.m": {},
"sap.ui.layout": {}
}
},
"contentDensities": {
"compact": true,
"cozy": true
},
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "Informations.i18n.i18n"
}
},
"":{
"dataSource": "InformationRemote",
"preload": true
}
},
"resources": {
"css": [
{
"uri": "css/style.css"
}
]
},
"routing": {
"config": {
"routerClass": "sap.m.routing.Router",
"viewType": "XML",
"async": true,
"viewPath": "Informations.view",
"controlAggregation": "pages",
"controlId": "app",
"clearControlAggregation": false
},
"routes": [
{
"name": "RoutevwInformation",
"pattern": "RoutevwInformation",
"target": ["TargetvwInformation"]
}
],
"targets": {
"TargetvwInformation": {
"viewType": "XML",
"transition": "slide",
"clearControlAggregation": false,
"viewId": "Main",
"viewName": "Main"
}
}
}
}
}
拜托,我该怎么做才能看到模拟数据,我应该在 viewController 中实现一些东西吗? 我真的不知道该怎么做。
提前致谢
如果您使用的是 WebIDE,请务必设置正确的配置。
首先 select“运行 配置”,当您右键单击您的项目时。
弹出窗口出现,您可以在其中创建新的 运行 配置。在那里,您需要 select 复选框“运行 with mock data”。
现在您应该可以启动 运行 配置:
我知道该怎么做我只需要做这样的事情。
var oModel = new sap.ui.model.odata.v2.ODataModel("myUrl");
sap.ui.getCore().setModel(oModel);