cancel
Showing results for 
Search instead for 
Did you mean: 

Changing default model data

Former Member
0 Kudos

Hey,

in my Fiori App my model is instantiated with automatic model instantiation SAPUI5 SDK - Demo Kit

Now I want to access the parameter of the default model in my Component. I have found a way to access the i18n model of my App, but I dont know how to access the default model, because it has no name.

Here is a little code snippet where I read my i18n.

   var oModels = this.getMetadata().getModels();
   var sNamespace = this.getMetadata().getManifestEntry("sap.app").id;
   var oi18nModel = new JSONModel(jQuery.sap.getObject(sNamespace, oModels.i18n));
   this.setModel(oi18nModel, "");
  
   var oModelsNew = this.getMetadata().getModels();
  

console.log("Ausgabe: " + JSON.stringify(oModelsNew.i18n));

In line 3 I can access the model with oModels.i18n, but how to get the default model?

Thanks for your help,

Best regards,

David

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

This works fine! Thank you very much!

Can you also give me a hint how to modify this values now? Espacially I want to add a header value.

Best regards,

David

Former Member
0 Kudos

simply using

this.getModel() will return default model from Component.js

saivellanki
Active Contributor
0 Kudos

Hi David,

Can you try something like this:


var oModels = this.getMetadata().getModels();

var oModel = oModels[""];

Regards,

Sai.