cancel
Showing results for 
Search instead for 
Did you mean: 

Read the default model in Sap Web Ide

rogerio_ribeiro2
Explorer
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

karanshaheri
Participant

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.

rogerio_ribeiro2
Explorer

Hi Karan,

it worked, thank you.

If it wasn't a default model, what would change please?

Thank you

Answers (1)

Answers (1)

0 Kudos

Rogerio if its not a default model then we will have to pass the model name. this.getView().getModel("modelName")