on 06-01-2017 6:47 AM
Hello,
I would like your help to access models in the Sap Web Ide, using the manifest.json. Previously, I used to instantiate a JSONModel and then could access this model using its ID.
var oUserDataModel = new sap.ui.model.json.JSONModel(data);
sap.ui.getCore().setModel(oUserDataModel, "UserData");
var modelUser = sap.ui.getCore().getModel("UserData");
However, using the manifest.json, especially when it is the default model, I don't know how to access this model in order to make some changes in its structure.
Is it possible to do read models in the same way with these created in manifest? For example...
var modelUser = sap.ui.getCore().getModel("Default");
And when it isn't a default model? What would change?
I have attached a print screen of my manifest.json, with an example from Northwind oData.
Thank you in advance, Rogerio
Hi,
I can see you are instantiating OData Model as default model.
So if you are accessing the model from Component controller, you can access it using below code :
var oModel = this.getModel();
If you want to access it in controllers, use below code :
var oModel = this.getOwnerComponent().getModel();
As your Odata model is a default model, no need to pass any model name in getModel() method.
I hope you are clear with the above explanation.
Regards,
Karan Shaheri.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Karan,
it worked, thank you.
If it wasn't a default model, what would change please?
Thank you
Rogerio if its not a default model then we will have to pass the model name. this.getView().getModel("modelName")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.