首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将$count放入瓷砖中

如何将$count放入瓷砖中
EN

Stack Overflow用户
提问于 2021-12-10 13:34:28
回答 1查看 443关注 0票数 -1

我是一个ABAP开发人员,他只是尝试在SAPUI5 5/Fiori中迈出第一步。

因此,我非常简单的任务是创建一个fiori应用程序,其中包含一个瓷砖,以显示EDIDC记录的数量。

View1.controller.js:

代码语言:javascript
复制
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:

代码语言:javascript
复制
<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“。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-12-13 10:26:39

​,我的第一个错误是插入文件的平铺,而不是数字内容。因此,首先,我将ID提供给数字内容:​

代码语言:javascript
复制
<NumericContent scale="M" value="" valueColor="Error" indicator="Up" withMargin="false" id="num1"/>

然后,对​​行进行了调整,以访问对象:

代码语言:javascript
复制
var oTileValue = this.getView().byId("num1");

​我学到的最后一件事是,模型与视图相连。因此,为了访问它,我将行更改为:

代码语言:javascript
复制
​this.getView().getModel().read("/EDIDCSet/$count", {

现在我可以调用我的函数onGetValue,它可以工作了。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/70305334

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档