Skip to Content
author's profile photo Former Member
Former Member

Changing default model data

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Posted on Jul 25, 2016 at 11:50 AM

    Hi David,

    Can you try something like this:

    var oModels = this.getMetadata().getModels();
    var oModel = oModels[""];
    

    Regards,

    Sai.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Jul 25, 2016 at 11:56 AM

    simply using

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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Jul 25, 2016 at 11:58 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.