I am currently working on single Tiles and want to add some count values from the Northwind OData service. The app contains just one view and one controller.
View
<mvc:View
controllerName="customtileapp.controller.CustomTile1"
xmlns="sap.m"
xmlns:mvc="sap.ui.core.mvc"
>
<GenericTile
class="sapUiTinyMarginBegin sapUiTinyMarginTop tileLayout"
header="Country-Specific Profit Margin"
subheader="Expenses" press="press"
>
<TileContent
unit="EUR"
footer="Current Quarter"
>
<NumericContent
scale="M"
value="{
path: '/Customers',
formatter: '.formatTile'
}"
valueColor="Error"
indicator="Up"
formatterValue="true"
/>
</TileContent>
</GenericTile>
</mvc:View>
Controller
sap.ui.define([
"sap/ui/core/mvc/Controller",
"sap/m/MessageToast",
"sap/ui/model/odata/v2/ODataModel"
], function (Controller, MessageToast, ODataModel){
"use strict";
return Controller.extend("customtileapp.controller.CustomTile1", {
onInit: function() {
this.oView = this.getView();
this.oModel = new ODataModel("/northwind/V2/Northwind/Northwind.svc");
this.oView.setModel(this.oModel);
},
formatTile: function() {
var counter;
this.oModel.read("/Customers/$count", {
async : true,
success : function(oData, response) {
counter = response.body;
MessageToast.show(counter);
}
});
return counter;
}
});
});
The MessageToast inside the formatter Function works fine and shows the correct number of customers ("91"
). But the number I want to show on the tile always shows "0"
.