我是一个ABAP开发人员,他只是尝试在SAPUI5 5/Fiori中迈出第一步。
因此,我非常简单的任务是创建一个fiori应用程序,其中包含一个瓷砖,以显示EDIDC记录的数量。
View1.controller.js:
sap.ui.define([
"sap/ui/core/mvc/Controller"
], function (Controller) {
"use strict";
return Controller.extend("QuickStartApplication.controller.View1", {
onGetValue: function ( ) {
var oTileValue = this.getView().byId("tile1");
this.getModel().read("/EDIDCSet/$count", {
success: $.proxy(function (oEvent, oResponse) {
// var count = Number(oResponse.body);
var count = "1337";
oTileValue.setValue(count);
}, this)
});
}
});
});View1.view.xml:
<mvc:View xmlns:html="http://www.w3.org/1999/xhtml" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"
controllerName="QuickStartApplication.controller.View1">
<App id="idAppControl">
<pages>
<Page xmlns="sap.m" id="pageId" title="TileTest" floatingFooter="true">
<content>
<Button xmlns="sap.m" text="Button" id="button0" press=".onGetValue"/>
<GenericTile class="sapUiTinyMarginBegin sapUiTinyMarginTop tileLayout" header="Country-Specific Profit Margin" subheader="Expenses"
press="press" id="tile1">
<TileContent unit="EUR" footer="Current Quarter">
<NumericContent scale="M" value="1000" valueColor="Error" indicator="Up" withMargin="false"/>
</TileContent>
</GenericTile>
</content>
</Page>
</pages>
</App>
</mvc:View>正如您所看到的,我甚至不能传递我硬编码的值"1337“。
发布于 2021-12-13 10:26:39
,我的第一个错误是插入文件的平铺,而不是数字内容。因此,首先,我将ID提供给数字内容:
<NumericContent scale="M" value="" valueColor="Error" indicator="Up" withMargin="false" id="num1"/>然后,对行进行了调整,以访问对象:
var oTileValue = this.getView().byId("num1");我学到的最后一件事是,模型与视图相连。因此,为了访问它,我将行更改为:
this.getView().getModel().read("/EDIDCSet/$count", {现在我可以调用我的函数onGetValue,它可以工作了。
https://stackoverflow.com/questions/70305334
复制相似问题