on 07-25-2016 12:38 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
simply using
this.getModel() will return default model from Component.js
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi David,
Can you try something like this:
var oModels = this.getMetadata().getModels();
var oModel = oModels[""];
Regards,
Sai.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
78 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.