Friday, November 11, 2016

Create new global JSON Model in a Fiori App

Step-1:

IN manifest.json


in  node "sap.ui5"-> "models":{}

Add custom model name after i18n

"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "chg.i18n.i18n"
}
},
"": {
"dataSource": "mainService",
"preload": true
},
"op":{
"type": "sap.ui.model.odata.JSONModel"
}
},

Step 2:

In Component.js

 Create model and add dummy data to model

var oData = {
            recipient : {
               name : "World"
            }
         };
         var oModel = new sap.ui..model.json.JSONModel(oData);
         this.setModel(oModel,'op');


Step3:

In any controller u can use this model and get / store data.
in main.controller.js

var data = this.getView().getModel('op').getData();

No comments:

Post a Comment

Post Ads (Documentation Required)

Phani Kumar

I am a SAP Technology enthusiast.
I am working on SAP technologies and various integrations.
SAP Fiori
SAP Gateway OData Development
SAP UI5
SAP Hana Cloud Platform
Internet of Things
Augmented Reality and Virtual Reality