Good morning Everyone,
I have a problem since a couple of days. I have a StandardTile control which I have integrated in the XML View. In my view Controller I want to set the property "title" of my StandardTile control using data binding. The needed data must come from a Gateway OData Service. My Gateway OData service is working and when the GET_ENTITYSET method is called, it returns ONE row with the desired data in ONE of the fields. I instantiated my OData model in the view Controller and set it to my StandardTile as Model. Now when I used the bindProperty method, the Data is not been passed to the "title" property of my StandardTile control. What am I doing wrong? Below is my View and Controller codes. Please I will appreciate any hint, I am still a learner in this field. Thanks in advance for your help and have a great day
View Code:
-------------
<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"
controllerName="zxyzcfm_cpc_bao.BAOOverviewView" xmlns:html="http://www.w3.org/1999/xhtml"
>
<FlexBox justifyContent="Center" alignItems ="Start">
<items>
<StandardTile
id = "idStandardTile"
info = "XYZ Demo Apps"
icon = "image/xyzlogo.png"
number = "Kontostandübersicht"
infoState = "Success"
type = "None"
iconDensityAware = "true"
>
</StandardTile>
</items>
</FlexBox>
</core:View>
------------------------------------
Controller code:
sap.ui.controller("zxyzcfm_cpc_bao.BAOOverviewView", {
/**
* Called when a controller is instantiated and its View controls (if available) are already created.
* Can be used to modify the View before it is displayed, to bind event handlers and do other one-time initialization.
* @memberOf zxyzcfm_cpc_bao.BAOOverviewView
*/
onInit: function() {
// Root path to method: CPC_BAO_OverviewSet/
/*The main idea is to create the OData model instance and set it to the View. In the View now we
* will bind the corresponding properties of the model to ui controls properties*/
/* Now let's create the OData model instance. Before that we need to set other parameters like
* the URL to the Service and the custom parameters
*/
//Set the root URL to the Service ZXYZCFM_CPC_BAO_Overview
var sServiceUrlToZXYZCFM_CPC_BAO_Overview = "/sap/opu/odata/sap/XYZCFM_CPC_BAO_OVERVIEW_SRV/";
/* We need to define three variables that will store the key and value pair of the custom query
* parameters The custom query parameters are embedded inside a header and tail pattern.
* For that pattern we also need two variables
* */
var sCustomQueryParamsHeader= "?customparam=start";
var sCustomQueryParamsTail= "customparam=end";
//Get Key date from the MainView by its element id
var sKeyDate= "KEYDATE=" + sap.ui.getCore().byId("idFieldKeyDate").getYyyymmdd();
/* Get the Curr_Plan from the MainView. The Currency is actually saved under the property
* key of the MultiInput control token. So we first have to get the MultiInput control
* through its id and then get the key from the token
* */
var oMultiInput = sap.ui.getCore().byId("idFieldCurrPlan");
var oTokens = oMultiInput.getTokens();
var sCurrenyKey = oTokens[0].getKey();
var sCurrPlan= "CURR_PLAN=" + sCurrenyKey;
var sCustomQueryParams = sCustomQueryParamsHeader+"&"+ sKeyDate+"&"+
sCurrPlan+"&"+sCustomQueryParamsTail;
var oModelZXYZCFM_CPC_BAO_Overview = new sap.ui.model.odata.ODataModel(sServiceUrlToZXYZCFM_CPC_BAO_Overview, {
json: true,
defaultCountMode: "NONE"
});
var oStandardTile = this.getView().byId("idStandardTile");
if(oStandardTile!=undefined)
{
//Set the Currency as NumberUnit
oStandardTile.setNumberUnit(sCurrenyKey);
//Set the model to the StandardTile control
oStandardTile.setModel(oModelZXYZCFM_CPC_BAO_Overview,"bao");
//Now bind the title property of the StandardTile to the model property BalanceDPc
//oStandardTile.setTitle("-467.890.567");
oStandardTile.bindProperty("title",{
path : "CPC_BAO_OverviewSet/BalanceDPc",
model : "bao"
});
}
},