Skip to Content
0
Aug 16, 2017 at 12:38 PM

SAPUI5 not all JSON file data is showing up in the controller

182 Views Last edit May 27, 2020 at 07:42 AM 2 rev

Dears,

I've created JSON model in my webIDE project. and I've used only two of its attributes in my the view. But when I try to call JSON file data in the controller the consol.log shows only the two used items and ignores the rest.

JSON file:

{
	"DocNum": "111",
	"FormNo": "10",
	"EmpNum": "00020000",
	"Amount": "1000.00",
	"Currency": "USD",
	"Beneficiary": "0020000050",
	"ReqFor": "D"
}

Component.js file

var oModel = new JSONModel("./model/CreateData.json");
oModel.setDefaultBindingMode("OneWay");
this.setModel(oModel, "CreateData");

Controller.js file

PostData: function(oEvent){        		
    var oModel = this.getOwnerComponent().getModel("CreateData");
    console.log(oModel);
}

View.xml file

<mvc:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:html="http://www.w3.org/1999/xhtml" controllerName="PayTest.controller.CreateView">
<App>
  <pages>
  <Page title="{CreateData>/Beneficiary}" showNavButton="true" navButtonPress="onNavBack">
  <content>
	<Button text="{CreateData>/EmpNum}" width="100px" id="__button0" press="PostData"/>
  </content>
  </Page>
  </pages>
  </App>
</mvc:View>

Is there is any explanation for that?

Note: same behaviour when loading it in the manifest.json file