我正在尝试使用Northwind R/W OData服务链接:
http://services.odata.org/V3/(S(frik5l2zde0sxh4jiifyhqo4))/OData/OData.svc/ as
proxy/http/services.odata.org/V3/(S(frik5l2zde0sxh4jiifyhqo4))/OData/OData.svc
Run Code Online (Sandbox Code Playgroud)
这对本地测试工作正常.现在,当我想将它ftp到我的域名时,它不起作用......
NetworkError:404 Not Found - http:// {mydomain} /proxy/http/services.odata.org/V3/(S(frik5l2zde0sxh4jiifyhqo4))/OData/OData.svc/$metadata
使用它无需代理就像http://services.odata.org/V3/(S(frik5l2zde0sxh4jiifyhqo4))/OData/OData.svc/给误差
NetworkError:501未实现
码:
onInit: function() {
var serviceUrl = "http://services.odata.org/V3/(S(frik5l2zde0sxh4jiifyhqo4))/OData/OData.svc/";
var oModel = new sap.ui.model.odata.ODataModel(serviceUrl);
oModel.oHeaders = {
"DataServiceVersion": "3.0",
"MaxDataServiceVersion": "3.0"
}
sap.ui.getCore().setModel(oModel, "products");
}
Run Code Online (Sandbox Code Playgroud) 我在UI5应用程序的Component.js中声明了一个模型,如下所示
init: function() {
sap.ui.core.UIComponent.prototype.init.apply(this);
var oModel1 = new sap.ui.model.json.JSONModel("model/mock.json");
sap.ui.getCore().setModel(oModel1, "oModelForSales");
},
Run Code Online (Sandbox Code Playgroud)
但是无法onInit在控制器内部的任何方法中访问模型,除非在视图上设置模型,如下所示:
var oModel1 = new sap.ui.model.json.JSONModel("model/routes.json");
this.getView().setModel(oModel1);
Run Code Online (Sandbox Code Playgroud)
sap.ui.getCore().getModel("oModelForSales")控制器onInit中的日志显示模型为,undefined但我能够在onBeforeRendering处理程序中获取它.
为什么在Component.js中设置的核心模型无法访问onInit?
我正在使用sap.m.ObjectListItem我的列表项,我从API绑定了JSON数据.但是,当我按下某个项目时,我找不到从列表中获取所选项目的方法.即使获得该项目的关键也会有所帮助.
<List id="ObjectList"
itemPress=".onPressDcData"
items="{DC>/}"
>
<ObjectListItem
type="Active"
title="{DC>Name}"
/>
</List>
Run Code Online (Sandbox Code Playgroud) 我在 SAPUI5 应用程序中有一个 Detail 视图,其中包含一个 ID 的输入字段"bestellmenge_tu"。每当调用此视图时,焦点应位于该输入字段上。不幸的是,当在控制器的onInit方法中将焦点设置在字段上时,焦点将被设置,但几毫秒后 UI5 将其拿走并将其转移到详细信息视图的“导航返回”按钮。
通过将 alog.trace()放在输入字段的blur事件上,我发现焦点被一个sap.ui.define.NavContainer._afterTransitionCallback被调用的方法夺走了,该方法被异步调用(window.setTimeout触发器和执行之间的一些s)。该函数只是在视图中查找第一个可聚焦的元素,然后粗暴地将焦点切换到它上面。
我的解决方法是重新定义jQuery.fn.firstFocusableDomRef用于查找“第一个可聚焦元素”的方法:
// DIESE KANONE FUNKTIONIERT
jQuery.fn.firstFocusableDomRef = (function() {
var _default = jQuery.fn.firstFocusableDomRef;
return function() {
var bestellmenge_tu = document.querySelector("input[id$='bestellmenge_tu-inner']");
if (bestellmenge_tu &&
bestellmenge_tu.style.display !="none" &&
bestellmenge_tu.style.visibility != "hidden") return bestellmenge_tu;
else return _default.apply(this);
}
})();
Run Code Online (Sandbox Code Playgroud)
但这可能是一个性能问题(querySelector在此后的任何页面加载的DOM 横向期间调用),并且对于所需的效果来说代码太多。
有没有更简单的方法来实现这一目标?
我想到了类似的东西
<mvc:View controllerName="zrt_dispo.view.Detail"...>
<Page id="detailPage" initialFocus="bestellmenge_tu"> <!-- ID of the element to …Run Code Online (Sandbox Code Playgroud) 我有一个要求,通过传递名称,它应该返回一个头像图标,其中包含该名称中包含的单词的第一个字母。例如:如果我通过 John Abraham,它应该返回一个带有“JA”的图标。
我需要在 SAPUI5 控件中使用该图标。我对此没有任何想法。如何实施?任何帮助表示赞赏。
我用这行来在我的view.xml中定义一个canvas元素:
<core:HTML content="<div class="wrapper col-6"><canvas id="
myChart"width="800"height="400"></canvas></div>">
</core:HTML>
Run Code Online (Sandbox Code Playgroud)
现在我想获取控制器中的元素,但this.getView().byId("myChart")即使站点成功加载带有ID的画布,典型似乎也不起作用.
有没有办法core:HTML在控制器的标签内定义这些类型的元素?
如果没有,是否有不同的方法来创建画布或其他HTML元素,以便我可以使用ID引用它们/在控制器中使用它们?
在调用后尝试第二次打开对话框片段时,出现以下错误this._oDialog.destroy():
未捕获的类型错误:无法读取 null 的属性“setInitialFocusId”
我的问题就像这里提到的问题:How to clear dialog/xmlfragment content after close? 但是,解决方案显然只是“不要使用属性 setInitialFocus”,我没有在代码中的任何地方使用它。
openDialog: function() {
if (!this._oDialog) {
this._oDialog = sap.ui.xmlfragment("myFragmentPath", this);
this.getView().addDependent(this._oDialog);
}
this._oDialog.open();
},
onExit: function () {
if (this._oDialog) {
this._oDialog.destroy();
}
},
afterClose: function () {
if (this._oDialog) {
this._oDialog.destroy();
}
},
handleClose: function (oEvent) {
this._oDialog.close();
}
Run Code Online (Sandbox Code Playgroud)
openDialog: function() {
if (!this._oDialog) {
this._oDialog = sap.ui.xmlfragment("myFragmentPath", this);
this.getView().addDependent(this._oDialog);
}
this._oDialog.open();
},
onExit: function () {
if (this._oDialog) {
this._oDialog.destroy(); …Run Code Online (Sandbox Code Playgroud) 我有一个UI5-JSON-Model,并希望将其显示在树中。但我不想显示整个结构,而只显示一个子集。说我有以下模型:
{
"nodes": [
{
"text": "Leaf 1",
"additionalStuff": [
{
"element": "blue"
},
{
"element": "green"
}
]
},
{
"text": "Subtree",
"nodes": [
{
"text": "Leaf in Subtree"
}
]
},
{
"text": "Leaf 2"
}
]
}
Run Code Online (Sandbox Code Playgroud)
我想显示nodes和text,但不显示additionalStuff。但是我得到的图片如下:
我如何告诉树忽略additionalStuff?
我知道如何在 node.js 中使用 npm 管理的库(例如uuid. 但是,在基于浏览器的 SAP UI5 JavaScript 代码中执行此操作的好方法是什么?
我参考了这个问题和答案To get total and subtotal without loop in new abap。但我的要求比这简单得多。我只需要带有相应总数的类别。
我有内部表,如:
Category Amount
AAA 10
AAA 20
BBB 30
CCC 40
CCC 50
CCC 60
Run Code Online (Sandbox Code Playgroud)
我需要像这样构建内部表:
Category Amount
AAA 30
BBB 30
CCC 150
Run Code Online (Sandbox Code Playgroud)
有人能帮忙吗?